Q_Id
int64
337
49.3M
CreationDate
stringlengths
23
23
Users Score
int64
-42
1.15k
Other
int64
0
1
Python Basics and Environment
int64
0
1
System Administration and DevOps
int64
0
1
Tags
stringlengths
6
105
A_Id
int64
518
72.5M
AnswerCount
int64
1
64
is_accepted
bool
2 classes
Web Development
int64
0
1
GUI and Desktop Applications
int64
0
1
Answer
stringlengths
6
11.6k
Available Count
int64
1
31
Q_Score
int64
0
6.79k
Data Science and Machine Learning
int64
0
1
Question
stringlengths
15
29k
Title
stringlengths
11
150
Score
float64
-1
1.2
Database and SQL
int64
0
1
Networking and APIs
int64
0
1
ViewCount
int64
8
6.81M
3,103,145
2010-06-23T15:38:00.000
0
0
0
0
python,amazon-simpledb,boto
9,012,699
3
false
1
0
I have had the same issue as you Charlie. After profiling the code, I have narrowed the performance problem down to SSL. It seems like that is where it is spending most of it's time and hence CPU cycles. I have read of a problem in the httplib library (which boto uses for SSL) where the performance doesn't increase unless the packets are over a certain size, though that was for Python 2.5 and may have already been fixed.
1
2
0
I am trying to use the SimpleDB in following way. I want to keep 48 hrs worth data at anytime into simpledb and query it for different purposes. Each domain has 1 hr worth data, so at any time there are 48 domains present in the simpledb. As the new data is constantly uploaded, I delete the oldest domain and create a new domain for each new hour. Each domain is about 50MB in size, the total size of all the domains is around 2.2 GB. The item in the domain has following type of attributes identifier - around 50 characters long -- 1 per item timestamp - timestamp value -- 1 per item serial_n_data - 500-1000 bytes data -- 200 per item I'm using python boto library to upload and query the data. I send 1 item/sec with around 200 attributes in the domain. For one of the application of this data, I need to get all the data from all the 48 domains. The Query looks like, "SELECT * FROM domain", for all the domains. I use 8 threads to query data with each thread taking responsibility of few domains. e.g domain 1-6 thread 1 domain 7-12 thread 2 and so on It takes close to 13 minutes to get the entire data.I am using boto's select method for this.I need much more faster performance than this. Any suggestions on speed up the querying process? Is there any other language that I can use, which can speed up the things?
SimpleDB query performance improvement using boto
0
1
0
1,743
3,104,281
2010-06-23T18:05:00.000
3
0
1
0
c#,java,javascript,c++,python
3,104,317
3
false
0
0
All of these have space complexity O(n). All that changes is the coefficient, and that is completely dependent on the implementation. Especially when you start getting into things like pre-allocating space to reduce time complexity. For instance, array list structures generally pre-allocate extra space. Therefore, their exact complexity for a number of objects is actually a range which is completely dependent on implementation and how they were created and used. For instance, if I write an array list that always allocates three extra spaces whenever more space is necessary, and always deallocates down to three open spaces when there's more than 5 open spaces, then actual complexity for n will be [n, n + 5] + overhead. The big differences in choosing between these items when programming is usually ease-of-use and how well it fits with how you will be using it. For example, linked lists are horrible for random access, but great at iteration.
3
2
0
I want to know the space complexities of the basic data structures in popular languages.
What is the space complexity of HashTable, Array, ArrayList, LinkedList etc(if anything more)
0.197375
0
0
5,569
3,104,281
2010-06-23T18:05:00.000
2
0
1
0
c#,java,javascript,c++,python
3,104,329
3
false
0
0
For Java: (Aproximates) Memory O(x) | General Case Array | n | n ArrayList | n | 2 * n LinkedList| n | n * (node size) HashTable | n | ~n Map | n | (n * key_size) + n
3
2
0
I want to know the space complexities of the basic data structures in popular languages.
What is the space complexity of HashTable, Array, ArrayList, LinkedList etc(if anything more)
0.132549
0
0
5,569
3,104,281
2010-06-23T18:05:00.000
1
0
1
0
c#,java,javascript,c++,python
3,104,311
3
false
0
0
Virtually all data structures with a non-trivial size are on the ORDER of n. Array = exactly n ArrayList = betweenn and k*n (default k=2) LinkedList = exactly n HashTable = worst is n/k (default k is .75)
3
2
0
I want to know the space complexities of the basic data structures in popular languages.
What is the space complexity of HashTable, Array, ArrayList, LinkedList etc(if anything more)
0.066568
0
0
5,569
3,105,705
2010-06-23T21:30:00.000
1
0
0
1
python,sockets
3,107,066
3
false
0
0
Unfortunately, at this point in time the python libraries don't support the usual SCM_CREDENTIALS method of passing credentials along a Unix socket. You'll need to use an "ugly" method as described in another answer to find it.
1
2
0
If Python, if you are developing a system service that communicates with user applications through sockets, and you want to treat sockets connected by different users differently, how would you go about that? If I know that all connecting sockets will be from localhost, is there a way to lookup through the OS (either on windows or linux) which user is making the connection request?
Determine user connecting a local socket with Python
0.066568
0
1
195
3,105,747
2010-06-23T21:37:00.000
0
1
1
0
python,python-2.5,shutil,copytree
3,105,771
1
true
0
0
You can copy the source for copytree from the 2.6 tree, and put it into your project's source tree.
1
0
0
Short of essentially rewriting copytree to accept an ignore callback, what is a simple way to achieve this in versions prior to python 2.6? (I don't want to stray from my debian packages)
Python: shutil.copytree , lack of ignore arg in python 2.5
1.2
0
0
456
3,106,736
2010-06-24T01:43:00.000
9
0
1
0
python,pip
3,106,793
2
false
0
0
Pip has some great features for this. It lets you save all requirements from an environment in a file using pip freeze > reqs.txt You can then later do : pip install -r reqs.txt and you'll get the same exact environnement. You can also bundle several libraries into a .pybundle file with the command pip bundle MyApp.pybundle -r reqs.txt, and later install it with pip install MyApp.pybundle. I guess that's what you're looking for :)
2
2
0
I had one machine with my commonly used python package installed. and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?
Any productive way to install a bunch of packages
1
0
0
824
3,106,736
2010-06-24T01:43:00.000
0
0
1
0
python,pip
3,106,755
2
false
0
0
I keep a requirements.txt file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine. Each of my projects also has it's own requirements.txt file that contains all of it's dependencies for use w/virtualenv.
2
2
0
I had one machine with my commonly used python package installed. and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?
Any productive way to install a bunch of packages
0
0
0
824
3,106,788
2010-06-24T02:02:00.000
1
0
0
0
python,image,image-processing,colors
3,106,854
2
true
1
0
How about doing this? Blur the image using some fast blurring algorithm. (Search for stack blur or box blur) Compute standard deviation of the pixels in RGB domain, once for each color. Discard the image if the standard deviation is beyond a certain threshold.
1
1
1
I've read a number of questions on finding the colour palette of an image, but my problem is slightly different. I'm looking for images made up of pure colours: pictures of the open sky, colourful photo backgrounds, red brick walls etc. So far I've used the App Engine Image.histogram() function to produce a histogram, filter out values below a certain occurrence threshold, and average the remaining ones down. That still seems to leave in a lot of extraneous photographs where there are blobs of pure colour in a mixed bag of other photos. Any ideas much appreciated!
Finding images with pure colours
1.2
0
0
381
3,107,989
2010-06-24T07:37:00.000
0
0
0
0
python,serial-port
48,804,389
2
false
0
0
You say you don't have access to install anything new. I'm guessing it is a permissions issue - i.e. you can't obtain elevated administration access and pip install/conda install fails. If you have any kind of normal user login access to the machine (which I presume you must have either directly or indirectly in order to put your script on to the machine in the first place) then you can use a virtual environment to install the modules that you need. This can all be done from a normal user account. Just Google for "python virtual environment" and you'll find all you need. If you are using Anaconda Python it's slightly different. Google for "conda environment". If you can't even obtain a command prompt on the host PC - e.g. you zip up the files and give them to someone else to deploy - you can still use a virtual environment. You'll just have to zip up the virtual environment along with your script. With Anaconda you can arrange for the environment to be created in the same directory as your project by using the -p switch. I presume pipenv has something similar. Or you could package everything up with pyinstaller, which creates a stand-alone runtime with all the modules included.
1
6
0
I have to read a stream which is sent from a homemade device over the serial port. The problem is that it should be deployed on a machine where I don't have access to install anything new, which means I have to use the python standard libraries to do this. Is this possible, and if so, how can I manage this. If it turns out to be almost impossible, I will have to get someone to install pySerial, but I would really appreciate it if it could be done without this. If there is differences in Linux/Windows, this is on a Windows machine, but I would really appreciate a cross platform solution.
How to read from the serial port in python without using external APIs?
0
0
0
5,525
3,108,285
2010-06-24T08:25:00.000
-4
0
1
1
python,linux,unix,environment-variables
48,543,222
6
false
0
0
you can set PYTHONPATH, by os.environ['PATHPYTHON']=/some/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective.
1
146
0
I know how to set it in my /etc/profile and in my environment variables. But what if I want to set it during a script? Is it import os, sys? How do I do it?
In Python script, how do I set PYTHONPATH?
-1
0
0
173,492
3,108,941
2010-06-24T10:05:00.000
0
0
0
0
python,pyqt4
3,727,333
1
false
0
0
Problem seem to be solved using QNetworkAccessManager QNetworkAccessManager.proxyAuthenticationRequired(proxy, authenticator) proxy – QNetworkProxy authenticator – QAuthenticator
1
1
0
I'm confused a bit on usage of QWebPage via socks using httplib2 (http/socks5/socks4). Is there any issues or workaround on it?
Using QWebPage via socks
0
0
0
214
3,110,166
2010-06-24T13:05:00.000
5
0
0
0
python,django,templates,ternary-operator
3,110,234
6
false
1
0
You don't. The Django {% if %} templatetag has only just started supporting ==, and, etc. {% if cond %}{% else %}{% endif %} is as compact as it gets for now.
1
70
0
I was wondering if there was a ternary operator (condition ? true-value : false-value) that could be used in a Django template. I see there is a python one (true-value if condition else false-value) but I'm unsure how to use that inside a Django template to display the html given by one of the values. Any ideas?
Django Template Ternary Operator
0.16514
0
0
35,699
3,110,545
2010-06-24T13:49:00.000
3
0
0
0
python,svn
6,219,157
1
false
0
0
This error may be occurring because Python-on-Windows is performing newline conversions (treating stdin as a text file). Because "svnadmin dump" produces a dump file using Unix newline convention (even when run on Windows), you don't want python performing newline conversions. The solution is to invoke python with the "-u" option. Also, the first argument to svndumpfilter2.py is supposed to be a local REPOS_PATH, not an http:// string. Lets say for sake of discussion that your repository is called foo_bar and resides at c:\svnrepos\foo_bar. Let's also say you have run "svnadmin dump" already on foo_bar and produced a file called out.dump Then the proper python invocation is: C:\Python26\python.exe -u "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py" c:\svnrepos\foo_bar Project D:\svndump\project.dump
1
2
0
I'm attempting to migrate a project out of one repository into its own repository to more easily handle authentication/authorization via ldap. However, in attempting the svnadmin dump | svndumpfilter --include ... I get the standard error that some files in the included path were moved or copied from somewhere NOT in the included path, and thus the contents are not available. Google tells me that I need to use one of the svndumpfilter python script variants. I have python 2.6.5 on windows server 2003 accessible via the command line. All three of these scripts use standard input, but they each handle things a little different. svndumpfilter2 starts, but on Revision 2, chokes with an assertion failure. The code apparently expects a colon to be on that line, and there's not. The dump file I'm using is just a simple svnadmin dump repo > out.dump. Nothing has been done to it. The command(s) I'm using are: svnadmin dump D:\svn\repo | C:\Python26\python.exe "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py" http: //localhost/svn/repo include Project > D:\svndump\project.dump OR svnadmin dump D:\svn\repo > out.dump type out.dump | C:\Python26\python.exe "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py" http: //localhost/svn/repo include Project > D:\svndump\project.dump The output I get is: Dumped revision 0. Dumped revision 1. C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py:67: DeprecationWa rning: the md5 module is deprecated; use hashlib instead import md5 Traceback (most recent call last): File "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py", line 40 6, in lump = read_lump(fr) File "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py", line 23 9, in read_lump lump = read_rfc822_headers(f) File "C:\Program Files\CollabNet\Subversion Server\svndumpfilter2.py", line 23 1, in read_rfc822_headers assert colon > 0 AssertionError The first part of the dump file it's failing on is: SVN-fs-dump-format-version: 2 UUID: 880c8176-308d-ea4f-8680-45defe5ec145 Revision-number: 0 Prop-content-length: 56 Content-length: 56 K 8 svn:date V 27 2007-01-30T21:25:29.487250Z PROPS-END Revision-number: 1 Prop-content-length: 151 Content-length: 151 K 7 svn:log V 40 Folders added to allow proper branching. K 10 svn:author V 15 COMPANY\USER K 8 svn:date V 27 2007-02-02T21:02:22.321625Z PROPS-END Node-path: branch Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: tags Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Node-path: trunk Node-kind: dir Node-action: add Prop-content-length: 10 Content-length: 10 PROPS-END Revision-number: 2 Prop-content-length: 109 Content-length: 109 Has anyone seen this before or have any ideas why this would be occuring?
Extracting projects to their own repository in svn using svndumpfilter2 (python assertion error)
0.53705
0
0
1,059
3,110,967
2010-06-24T14:37:00.000
6
1
0
0
python,unit-testing,nose
3,118,573
5
true
0
0
You could try to play with -m option for nosetests. From documentation: A test class is a class defined in a test module that matches testMatch or is a subclass of unittest.TestCase -m sets that testMatch, this way you can disable testing anything starting with test. Another thing is that you can add __test__ = False to your test case class declaration, to mark it “not a test”.
1
6
0
My test framework is currently based on a test-runner utility which itself is derived from the Eclipse pydev python test-runner. I'm switching to use Nose, which has many of the features of my custom test-runner but seems to be better quality code. My test suite includes a number of abstract test-classes which previously never ran. The standard python testrunner (and my custom one) only ran instances of unittest.TestCase and unittest.TestSuite. I've noticed that since I switched to Nose it's running just about anything which starts withthe name "test" which is annoying... because the naming convention we used for the test-mixins also looks like a test class to Nose. Previously these never ran as tests because they were not instances of TestCase or TestSuite. Obviously I could re-name the methods to exclude the word "test" from their names... that would take a while because the test framework is very big and has a lot of inheritance. On the other hand it would be neat if there was a way to make Nose only see TestCases and TestSuites as being runnable... and nothing else. Can this be done?
Is it possible to make Nose only run tests which are sub-classes of TestCase or TestSuite (like unittest.main())
1.2
0
0
2,498
3,112,546
2010-06-24T17:48:00.000
1
0
0
1
python
3,112,744
2
false
0
0
The problem is related to the fact that the Python process runs in its own shell. When you run subprocess.Popen(shell=True) you are spawning a new shell, which is working around the issue you're experiencing. Python is not causing this issue. It's a combination of how NFS (file storage) and directory listings function in Linux.
1
14
0
I'm running a number of python scripts on a linux cluster, and the output from one job is generally the input to another script, potentially run on another node. I find that there is some not insignificant lag before python notices files that have been created on other nodes -- os.path.exists() returns false and open() fails as well. I can do a while not os.path.exists(mypath) loop until the file appears, and it can take upwards of a full minute, which is not optimal in a pipeline with many steps and potentially running many datasets in parallel. The only workaround I've found so far is to call subprocess.Popen("ls %s"%(pathdir), shell=True), which magically fixes the problem. I figure this is probably a system problem, but any way python might be causing this? Some sort of cache or something? My sysadmin hasn't been much help so far.
os.path.exists() lies
0.099668
0
0
7,646
3,113,573
2010-06-24T20:18:00.000
10
1
0
1
java,php,python,hadoop,mapreduce
3,113,643
3
true
1
0
PHP is designed primarily as a language for displaying output to a browser. Most jobs being run on MapReduce/Hadoop clusters have nothing to do with displaying output. They instead tend to lean much more heavily towards data processing. PHP is not the most commonly supported language for data processing, by far. Thus, it's logical that the most common supported languages for data processing-related technologies don't include PHP.
2
3
0
I'm beginning to learn some Hadoop/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. But, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. I've looked, and it looks like there are some Hadoop/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages. Is there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. If this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries/projects should I look into?
PHP vs. Other Languages in Hadoop/MapReduce implementations, and in the Cloud generally
1.2
0
0
906
3,113,573
2010-06-24T20:18:00.000
1
1
0
1
java,php,python,hadoop,mapreduce
3,113,644
3
false
1
0
The reason is PHP lack of support for multi-threading and process communication.
2
3
0
I'm beginning to learn some Hadoop/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python. But, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python. I've looked, and it looks like there are some Hadoop/MapReduce in PHP, but the overwhelming body of the literature seems to be dedicated to those 4 languages. Is there a good reason why PHP is a 2nd class language in cloud computing projects like those that involve Hadoop/MapReduce? This is particularly surprising, considering that, outside of cloud computing world, PHP seems like its the most commonly supported language, to the detriment of the 3 above (sans C++) languages. If this is arbitrary--if PHP is just as good at handling these operations as, say, Python, what libraries/projects should I look into?
PHP vs. Other Languages in Hadoop/MapReduce implementations, and in the Cloud generally
0.066568
0
0
906
3,113,734
2010-06-24T20:44:00.000
5
0
0
1
java,iphone,python,google-app-engine,google-cloud-datastore
3,113,823
1
true
1
0
Why not have the iPhone application communicate this information to app engine by making a simple HTTP request? Specifically, I would do an HTTP POST to the server and include the relevant fields. Then your app engine request handler would simply store the information in the datastore.
1
2
0
I'm working on an app that communicates with Google App Engine to update and retrieve user information, but I can't think of a way to modify elements in the datastore. For example, every user for my app is represented by a User object in the datastore. If this user inputs things like email, phone number, etc into fields inside the iPhone application, I want to be able to update those objects in the datastore. The datastore can be in Java or Python, I'm just looking for an idea that will work. Thanks
Update datastore in Google App Engine from the iPhone
1.2
0
0
411
3,113,929
2010-06-24T21:15:00.000
1
1
1
0
c++,python,exception-handling
3,113,950
4
false
0
0
If you want to know the name of the exception class, you could use RTTI. However, the vast majority of C++ code will throw an exception derived from std::exception. However, all you get is the exception data contained in std::exception::what, and you can get the name of the exception class from RTTI and catch that explicitly if you need more information (and it contains more information).
2
2
0
With Python, I could get the name of the exception easily as follows. run the code, i.e. x = 3/0 to get the exception from python "ZeroDivisionError: integer division or modulo by zero" tells me this is ZeroDivisionError Modify the code i.e. try: x=3/0 except ZeroDivisionError: DO something Is there any similar way to find the exception name with C++? When I run the x = 3/0, the compiled binary just throws 'Floating point exception', which is not so useful compared to python.
How can I know the name of the exception in C++?
0.049958
0
0
940
3,113,929
2010-06-24T21:15:00.000
1
1
1
0
c++,python,exception-handling
3,114,002
4
false
0
0
If this is a debugging issue, you may be able to set your compiler to break when it hits an exception, which can be infinitely useful.
2
2
0
With Python, I could get the name of the exception easily as follows. run the code, i.e. x = 3/0 to get the exception from python "ZeroDivisionError: integer division or modulo by zero" tells me this is ZeroDivisionError Modify the code i.e. try: x=3/0 except ZeroDivisionError: DO something Is there any similar way to find the exception name with C++? When I run the x = 3/0, the compiled binary just throws 'Floating point exception', which is not so useful compared to python.
How can I know the name of the exception in C++?
0.049958
0
0
940
3,114,788
2010-06-25T00:12:00.000
0
0
0
0
python,ruby-on-rails,ruby,frameworks
3,114,814
3
false
1
0
Rails will still be around in 5 years. So will C# (.net), silverlight etc. The Microsoft stack is too widely used to vanish.
2
0
0
Basically, we want to use no flash, and eschew php where possible (for marketing reasons). Right now, I'm looking at Ruby on Rails and like what I see... but I'm not really a programmer, having working primarily with Wordpress, Drupal, and Joomla for the past 10 years. Our sites need to have a lot of custom apps built into them (video uploading and galleries, user accounts, employee time logging, and more) with consistant looks. We don't expect to have any high-traffic sites (nothing in excess of 500 unique views in a day). Anyone think that Rails is Not a good choice for the next 5 years or so?
What's a good swiss-army framework for the next 5 years?
0
0
0
385
3,114,788
2010-06-25T00:12:00.000
1
0
0
0
python,ruby-on-rails,ruby,frameworks
3,114,824
3
false
1
0
I'd say python/Django over RoR. If you weren't avoiding PHP, Zend would be a safe(ish) bet for the next 5 years (probably). Mind you, you're by your own admission not a programmer and you're at least partially basing an engineering/technical decision on marketing (OMFG), so I'd be more worried about you lasting 5 years than any framework you choose...
2
0
0
Basically, we want to use no flash, and eschew php where possible (for marketing reasons). Right now, I'm looking at Ruby on Rails and like what I see... but I'm not really a programmer, having working primarily with Wordpress, Drupal, and Joomla for the past 10 years. Our sites need to have a lot of custom apps built into them (video uploading and galleries, user accounts, employee time logging, and more) with consistant looks. We don't expect to have any high-traffic sites (nothing in excess of 500 unique views in a day). Anyone think that Rails is Not a good choice for the next 5 years or so?
What's a good swiss-army framework for the next 5 years?
0.066568
0
0
385
3,115,286
2010-06-25T03:06:00.000
0
0
0
0
python,proxies
8,904,814
3
false
0
0
to use tor with mechanize I use tor+polipo. set polipo to use parent proxy socksParentProxy=localhost:9050 at confing file. then use browser.set_proxies({"http": "localhost:8118"}) where 8118 is your polipo port. so you are using polipo http proxy that uses sock to use tor hope it helps :)
1
3
0
Is it possible to filter all outgoing connections through a HTTPS or SOCKS proxy? I have a script that users various apis & calls scripts that use mechanize/urllib. I'd like to filter every connection through a proxy, setting the proxy in my 'main' script (the one that calls all the apis). Is this possible?
Python proxy question
0
0
1
798
3,116,195
2010-06-25T07:10:00.000
3
0
1
0
python,parsing
3,116,217
3
false
0
0
Load the text file into a string. Search the string for the first occurrence of <concept> using pos1 = s.find('<concept>') Search for </concept> using pos2 = s.find('</concept>', pos1) The words you seek are then s[pos1+len('<concept>'):pos2]
1
1
0
i need help with python programming: i need a command which can search all the words between tags from a text file. for example in the text file has <concept> food </concept>. i need to search all the words between <concept> and </concept> and display them. can anybody help please.......
python search from tag
0.197375
0
0
2,554
3,117,626
2010-06-25T11:35:00.000
4
0
1
0
python,32bit-64bit
50,668,641
7
false
0
0
I had trouble running python app (running large dataframes) in 32 - got MemoryError message, while on 64 it worked fine.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
0.113791
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
5
0
1
0
python,32bit-64bit
37,394,546
7
false
0
0
Use the 64 bit version only if you have to work with heavy amounts of data, in that scenario, the 64 bits performs better with the inconvenient that John La Rooy said; if not, stick with the 32 bits.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
0.141893
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
2
0
1
0
python,32bit-64bit
61,716,120
7
false
0
0
Machine learning packages like tensorflow 2.x are designed to work only on 64 bit Python as they are memory intensive.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
0.057081
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
6
0
1
0
python,32bit-64bit
3,117,679
7
false
0
0
You do not need to use 64bit since windows will emulate 32bit programs using wow64. But using the native version (64bit) will give you more performance.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
1
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
96
0
1
0
python,32bit-64bit
3,117,794
7
true
0
0
64 bit version will allow a single process to use more RAM than 32 bit, however you may find that the memory footprint doubles depending on what you are storing in RAM (Integers in particular). For example if your app requires > 2GB of RAM, so you switch from 32bit to 64bit you may find that your app is now requiring > 4GB of RAM. Check whether all of your 3rd party modules are available in 64 bit, otherwise it may be easier to stick to 32bit in the meantime
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
1.2
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
36
0
1
0
python,32bit-64bit
45,123,435
7
false
0
0
In my experience, using the 32-bit version is more trouble-free. Unless you are working on applications that make heavy use of memory (mostly scientific computing, that uses more than 2GB memory), you're better off with 32-bit versions because: You generally use less memory. You have less problems using COM (since you are on Windows). If you have to load DLLs, they most probably are also 32-bit. Python 64-bit can't load 32-bit libraries without some heavy hacks running another Python, this time in 32-bit, and using IPC. If you have to load DLLs that you compile yourself, you'll have to compile them to 64-bit, which is usually harder to do (specially if using MinGW on Windows). If you ever use PyInstaller or py2exe, those tools will generate executables with the same bitness of your Python interpreter.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
1
0
0
188,276
3,117,626
2010-06-25T11:35:00.000
0
0
1
0
python,32bit-64bit
67,392,455
7
false
0
0
I was using 32 bit version since getting the torch install error. Then i download 64 bit python problem solved.
7
148
0
I have a win7 64bit installation. Must I use Python 64bit? What are the differences between the 32bit and 64bit Python versions anyway? Do different Python packages (such as south, django, mysqldb etc) support only 32bit/64bit?
Should I use Python 32bit or Python 64bit
0
0
0
188,276
3,118,008
2010-06-25T12:35:00.000
4
0
1
0
python,module
3,118,063
3
false
0
0
There are a lot of ways to factor code so it is reusable. It really depends on your specific situation as far as what will work best. Factoring your code into separate packages and modules is always a good idea, so related code stays bundled together and can be reused from other packages and modules. Factoring your code into classes within a module can also help in keeping related code grouped together. I would say that putting common code into a module or package that is on your PYTHONPATH and available to both applications would probably be your best solution.
1
19
0
I'm currently maintaining two of my own applications. They both share some common aspects, and as a result, share some code. So far, I've just copied the modules from one project to the other, but now it's becoming a maintenance issue. I'd rather have the common code in one place, outside of both of the projects, which they can both import. Then, any changes to the common code would be reflected in both project. My question is: how can I do this? Do I create a library out of this code? If so, how do the dependent projects use the library? I think one thing I struggle with here is that the common code isn't really useful to anyone else, or at least, I don't want to make it a supported modules that other people can use. If my question isn't clear, please let me know.
How can I use common code in python?
0.26052
0
0
10,091
3,119,027
2010-06-25T14:59:00.000
3
1
0
0
python
3,120,074
1
true
0
0
If the 1553 interface has a Windows DLL, you can use the ctypes library to access it. I've done this for Python and my organization's 1553 products. To start, I would write a quick test that accesses a DLL function that doesn't access the 1553 hardware, or accesses the hardware in a very simple manner. If that succeeds, then you know that you can access the DLL. Once you know you can access the DLL then you can work on getting the rest of the DLL functions to work in Python.
1
3
0
Has anyone ever worked with MIL-STD-1553 in Python? How did you do it?
Tips on Python MIL-STD-1553
1.2
0
0
1,487
3,120,073
2010-06-25T17:28:00.000
0
0
1
0
java,python,perl,parsing
3,120,090
3
false
0
0
Why are you trying this in perl/python rather than just using a javadoc-aware program that can pull out the info?
1
5
0
I want to get a .java file, recognize the first class in the file, and get information about annotations, methods and attributes from this class. Is there any module in both languages that already does that? I could build up a simple regexp to do it also, but I don't known how to recognize in the regexp the braces indicating the end of the class/method.
Parsing Java Class From Perl or Python
0
0
0
2,385
3,120,430
2010-06-25T18:23:00.000
1
1
0
0
python,objective-c
3,120,602
2
true
0
0
NSMutableHTTPURLRequest, a category of NSMutableURLRequest, is how you set up an HTTP request. Using that class you will specify a method (GET or POST), headers and a url. NSURLConnection is how you open the connection. You will pass in a request and delegate, and the delegate will receive data, errors and messages related to the connection as they become available. NSHTTPCookieStorage is how you manage existing cookies. There are a number of related classes in the NSHTTPCookie family. With urlopen, you open a connection and read from it. There is no direct equivalent to that unless you use something lower level like CFReadStreamCreateForHTTPRequest. In Objective-C everything is passive, where you are notified when events occur on the stream.
1
0
0
Are there any equivalents in objective-c to the following python urllib2 functions? Request, urlopen, HTTPError, HTTPCookieProRequest, urlopen, HTTPError, HTTPCookieProcessor Also, how would I able to to this and change the method from "get" to "post"?
Is there an Objective-C equivalent to Python urllib and urllib2?
1.2
0
1
632
3,120,868
2010-06-25T19:31:00.000
1
0
1
0
python,byte,precision
3,122,098
2
false
0
0
Generally, thinking of a return value as a particular byte precision in Python is not the best way to go, especially with integers. For most intents and purposes, Python "short" integers are seamlessly integrated with "long" (unlimited) integers. Variables are promoted from the smaller to the larger type as necessary to hold the required value. Functions are not required to return any particular type (the same function could return different data types depending on the input, for example). When a function is provided by a third-party package (as this one is), you can either just trust the documentation (which for Murmur indicates 4-byte ints as far as I can tell) or test the return value yourself before using it (whether by if, assert, or try, depending on your preference).
1
2
0
I have a hash function in Python. It returns a value. How do I see the byte-size of this return value? I want to know if it is 4-bytes or 8 or what. Reason: I want to make sure that the min value is 0 and the max value is 2**32, otherwise my calculations are incorrect. I want to make sure that packing it to a I struct (unsigned int) is correct. More specifically, I am calling murmur.string_hash(`x`). I want to know sanity-check that I am getting a 4-byte unsigned return value. If I have a value of a different size, them my calculations get messed up. So I want to sanity check it.
Byte precision of value in Python?
0.099668
0
0
337
3,120,956
2010-06-25T19:47:00.000
1
0
0
0
python,django,active-directory,ldap,ntlm
3,787,434
1
true
1
0
Partial answer: You can (and should) pass the NTLM auth off to an external helper. Basically, install Samba on the machine, configure it, join the domain, enable winbind, then use the "ntlm_auth" helper binary, probably in "pipe" mode. Authenticating an NTLM session requires a secure pipe to the domain controller, which needs credentials (e.g. a Samba/domain-member machine account). This is the quickest route to get there. Squid (the webcache) has code for doing NTLM auth using the external helper; FreeRadius does something similar. The NTLM auth itself does not provide any group info; if you're running winbind you could of course use calls to "wbinfo" to get user groups.
1
0
0
I'm considering moving from Apache to Lighttpd for an internal web application, written with python. The problem is that I'm relying on libapache2-mod-auth-ntlm-winbind ... which doesn't actually seem to be a well support & updated package (though that could be because it really does work well). I'm looking for suggestions and hints about what it would take to use django itself to handle the HTTP authentication. This would allow me to be web-server-agnostic, and could potentially be a grand learning experience. Some topical concerns: Is it reasonable to have the custom application perform true HTTP authentication? How involved is getting my python code connected to windows domain controller to this kind of authentication without prompting the user for a password? Does NTLM provide any access to user details & group memberships so that I can stop searching through yet another connection to the windows domain controller via LDAP? I would love to be able to write a module to simplify this technique which could be shared with the community.
Django to do its own NTLM Authentication (HTTP Headers & all)
1.2
0
0
1,765
3,121,370
2010-06-25T20:52:00.000
1
0
1
0
python,list,io
3,121,406
4
true
0
0
I don't know whether this is applicable to your problem, but you might try it with numpy, especially its loadtxt and savetxt functions. You should then use only numpy arrays and avoid Python lists as they are not apt for numerical computations.
1
1
0
Today, as I tried to put together a script in Octave, I thought, this may be easier in python. Indeed the math operators of lists are a breeze, but loading in the file in the format is not as easy. Then I thought, it probably is, I am just not familiar with the module to do it! So, I have a typical data file with four columns of numbers. I would like to load each column into separate lists. Is there a module I should use to make this easier?
Math in python - converting data files to matrices
1.2
0
0
211
3,121,518
2010-06-25T21:17:00.000
0
0
0
0
python,xmpp,xmpppy
3,553,285
2
false
0
0
Good post. I notice this code snippet is also in the logger example in xmpppy sourceforge website. I wonder if it is possible to reply to incoming messages. The code above only receives and the nickname resource ID does not indicate who the sender is (in terms of JID format, user@server) unless xmpppy can translate that appropriately. So how might one take the received message nd "echo" it back to the sender? Or is that not easily possible with the xmpppy library and need to find a different XMPP library?
1
1
0
I'm using XMPP in Python, and I can send messages, but how can I receive?
How can I get a response with XMPP client in Python
0
0
1
3,190
3,122,291
2010-06-26T00:55:00.000
3
0
0
0
python,grid,tcl,rad
3,122,400
1
false
0
1
Tk has three methods. One is absolute positioning, the other two are called "grid" and "pack". grid is just what it sounds like: you lay out your widgets in a grid. There are options for spanning rows and columns, expanding (or not) to fill a cell, designating rows or columns which can grow, etc. You can accomplish probably 90% of all layout issues with the grid geometry manager. The other manager is "pack" and it works by requesting that widgets be placed on one side or another (top, bottom, left, right). It is remarkably powerful, and with the use of nested containers (called frames in tk) you can accomplish pretty much any layout as well. Pack is particularly handy when you have things stacked in a single direction, such as horizontally for a toolbar, vertically for a main app (toolbar, main area, statusbar). Both grid and pack are remarkably powerful and simple to use, and between them can solve any layout problem you have. It makes me wonder why Java and wxPython have so many and such complicated geometry managers when its possible to get by with no more than three.
1
0
0
I've been working with a few RAD gui builders lately. I absolutely despise CSS ( camel is a horse designed by committee etc.) What algorithms are used by packing managers(java/tk). Most GUI toolkits I've used have some alternative to absolute positioning, sorry for the ambiguity but how do you start thinking about implementing a packing manger in language X. Thanks for the replies, to clarify - I want to create a generic text file that defines a 'form' this form file can then be used to generated a native(ish) GUI form (eg tk) and also an HTML form. What I'm looking for is some pointers on how a grid based packing manager is implemented so I can formulate my generic text file based on some form of established logic. If this doesn't make sense to you then you understand me:). Some notes 1. XML lives in the same stable as the zebra and the camel but not the horse. 2. Think lightweight markup languages (Markdown/ReStructuredText) but for simple forms. 3. This has probably already been implemented, do you know where? 4. Yes, I have Googled it (many,many times),answer was not between G1 and o2 Thks
GUI layout -how?
0.53705
0
0
306
3,122,923
2010-06-26T06:10:00.000
0
0
0
0
python,ruby-on-rails,ruby,django
3,123,190
3
false
1
0
From what I have seen neither one looks like it will become a niche any time soon, both have active communities and dedicated developers. Ruby and python are both great languages, and both are being actively developed as well. At some point Django will have to migrate from python 2.x to 3.y, which may be a little bit painful, but the same sort of thing can be expected from rails at some point in the future. I think you have narrowed it down to the right two for being main stream yet not stagnant. They both have advantages and disadvantages, and if there isn't a clear reason to chose one or the other for your project, I would say go with the language you prefer. Python is my language of choice, so baring some killer reason to chose RoR, Django is the natural way to go to continue developing the way I like to. If you prefer ruby, I would recommend going with RoR unless Django seems to fit your application in a way RoR does not.
2
0
0
I'm in that horrible questioning state. I'm trying to decide between Django and Rails. From what I've read, Django probably fits my needs better, both from a "cultural" and goal point of view. The baked-in admin interface pretty much sells me alone. However, I have one critical concern: it looks like the Rails community is much larger. This could be a plus OR a minus; read on. I have experience hanging my hat on a technology that does not have as vibrant a commmunity as its "competitor." I run a Mac consulting firm in the Bay Area. Up until very, very recently (like the last year!), finding resources for very difficult issues (especially server- and network-related) was so difficult that it was often not even worth trying. This is now changing rapidly due to the Halo Effect, but if it wasn't for Steve Jobs' return to Apple and the iPhone, the future would look just as bleak as the past. So, while Django looks awesome, I am concerned about pigeonholing myself in yet another niche. I'm less concerned with my theoretical job prospects as a Django developer (I like my job) than I am with simply having resources available to create and maintain cutting-edge projects that can evolve with the Web, and not lag too far behind. From the above point of view, it looks like Rails has the advantage. However, here's a problem I've noticed that seems to come from the vibrancy of the Rails community: Want to accomplish a particular Rails programming task you've never done before? Google it; you'll find three to six+ different plugins, each with as many advocates as detractors. How do you decide which to use without spending hours and hours learning and prototyping? How do you know that the one you choose won't be end-of-lifed in 12 months, and you'll have to redo that part of your app in order to stay current with the latest Rails distribution? My latter point brings me right back to where I started: Django seems like a time-saver. Except now I have two reasons to think so, not just one. I should mention that I've already spent a significant amount of time learning Ruby and Rails, dabbled a bit in Python, and quite prefer Ruby. Would love your thoughts.
Django: vibrant community and future?
0
0
0
1,687
3,122,923
2010-06-26T06:10:00.000
0
0
0
0
python,ruby-on-rails,ruby,django
3,122,993
3
false
1
0
What about Pylons?
2
0
0
I'm in that horrible questioning state. I'm trying to decide between Django and Rails. From what I've read, Django probably fits my needs better, both from a "cultural" and goal point of view. The baked-in admin interface pretty much sells me alone. However, I have one critical concern: it looks like the Rails community is much larger. This could be a plus OR a minus; read on. I have experience hanging my hat on a technology that does not have as vibrant a commmunity as its "competitor." I run a Mac consulting firm in the Bay Area. Up until very, very recently (like the last year!), finding resources for very difficult issues (especially server- and network-related) was so difficult that it was often not even worth trying. This is now changing rapidly due to the Halo Effect, but if it wasn't for Steve Jobs' return to Apple and the iPhone, the future would look just as bleak as the past. So, while Django looks awesome, I am concerned about pigeonholing myself in yet another niche. I'm less concerned with my theoretical job prospects as a Django developer (I like my job) than I am with simply having resources available to create and maintain cutting-edge projects that can evolve with the Web, and not lag too far behind. From the above point of view, it looks like Rails has the advantage. However, here's a problem I've noticed that seems to come from the vibrancy of the Rails community: Want to accomplish a particular Rails programming task you've never done before? Google it; you'll find three to six+ different plugins, each with as many advocates as detractors. How do you decide which to use without spending hours and hours learning and prototyping? How do you know that the one you choose won't be end-of-lifed in 12 months, and you'll have to redo that part of your app in order to stay current with the latest Rails distribution? My latter point brings me right back to where I started: Django seems like a time-saver. Except now I have two reasons to think so, not just one. I should mention that I've already spent a significant amount of time learning Ruby and Rails, dabbled a bit in Python, and quite prefer Ruby. Would love your thoughts.
Django: vibrant community and future?
0
0
0
1,687
3,123,340
2010-06-26T09:15:00.000
1
1
0
0
c++,python,symbian,pys60
3,123,427
6
false
0
1
C++ is very, very fast, and the Qt library is for C++. If you're programming on a mobile phone, Python will be very slow and you'll have to spend ages writing bindings for it.
3
1
0
I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++. I want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?
PyS60 vs Symbian C++
0.033321
0
0
1,021
3,123,340
2010-06-26T09:15:00.000
1
1
0
0
c++,python,symbian,pys60
3,124,371
6
false
0
1
I answer this as a user. PyS60 is slow and not so much app and sample to start with. C++ is good, native, fast, but if you mind deevelop app for most device (current N-series), you will not want to go with Qt, I have a N78 and tested Qt in N82 too, it's slow (more than Python, sadly but true)
3
1
0
I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++. I want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?
PyS60 vs Symbian C++
0.033321
0
0
1,021
3,123,340
2010-06-26T09:15:00.000
0
1
0
0
c++,python,symbian,pys60
3,131,900
6
false
0
1
What is the purpose of your programming? Are you planning distribute your app through Ovi Store? If so, you should use a tool that could be tested and signed by Symbian Signed. What does it mean? As far as I know, they don't provide such functionality for Python. So you have to choose native Symbian C++ or Qt. By the way, Qt signing procedure is not quite clear for now. It seems Ovi Store and Symbian Signed are only allow Qt apps for a certain devices (Nokia X6, Nokia N97 mini, maybe some other). I suppose it is a subject for a change, and quite fast change, but you should consider this too.
3
1
0
I'm planning some Symbian related development on S60 3.1 platform. It seems like generally available language options are Python and C++. However Nokia's official forum seems very much tilted towards C++. I want to know what are the advantages and disadvantages of using Python for S60 over Symbian C++? And is it even possible to do Python programming for S60 3.1 platform?
PyS60 vs Symbian C++
0
0
0
1,021
3,123,683
2010-06-26T11:25:00.000
0
0
0
0
python,django
3,123,705
5
false
1
0
You definitely don't have to use a database with Django. Whether it fits your needs, only you can tell. There are other Python web frameworks that you can use.
1
3
0
I'm developing an app (an API) in python and I would like to offer some of its functionality through a web interface (like web services do). I've been looking at django, but I don't know if really fits well in my idea. I only want to create a web page that invokes to my API methods in order to acomplish the functionality that offers that web page. But, after followed the tutorial, I feel a little confused about the point of django. It seems to me to be more related with an ORM than a classic web application. Is django a solution so heavy for such a simple development (as I mentioned, make calls to my API through the web)? Do I always have to use a database? Thanks.
Django for a simple web application
0
0
0
2,020
3,123,801
2010-06-26T12:05:00.000
1
0
0
0
python,django,orm
3,125,012
1
false
1
0
If you can connect to the database remotely, then you can simply specify its host/port in settings.py exactly as you would a local one.
1
0
0
Can I somehow work with remote databases (if they can do it) with the Django ORM? It is understood that the sitting has spelled out the local database. And periodically to make connection to various external databases and perform any sort of commands such as load dump.
Remote execution of commands using the Django ORM
0.197375
1
0
121
3,125,021
2010-06-26T18:23:00.000
1
0
1
0
python,validation,phone-number
3,125,051
3
true
0
0
I studied this subject for a while. We have a huge database with numbers, no one knows are they with contry code or not. General answer is: it is impossible to find it out. We had some numbers that were valid US numbers without country code (1) and valid numbers of some other contries with area code. But for 99% cases you can check if length of number is 9 then there is no contry code. You should enforce users to enter contry code.
2
5
0
Is there an easy way to check whether a phone number entered by the user includes country code and to validate that the number is correct? I don't use any specific formats, the number itself must be only digits, no ('s, -'s and the like. Is such validation possible without asking user for a country? The trick is that I want to work with all numbers world-wide. I guess it can't be done with regex (googled a bit and found lots of stuff but not for this problem). Is there any library for it? I'm using python. Or maybe it would make more sense to enforce a format e.g. X-YYYYYYYY... where X would be a country code, or something like this?
How to check if phone number entered by user includes country code?
1.2
0
0
4,020
3,125,021
2010-06-26T18:23:00.000
2
0
1
0
python,validation,phone-number
7,593,489
3
false
0
0
A number like 247 8000 could be: the local number 247 8000 in an unspecified area in an unspecified country, maybe +1 212 247 8000 the local number 8000 in the 247 area code in an unspecified country, maybe +269 247 8000 the local number 8000 in the 247 country code, as +247 8000 Without further context it is impossible to tell. The + symbol is vital in identifying the country code part.
2
5
0
Is there an easy way to check whether a phone number entered by the user includes country code and to validate that the number is correct? I don't use any specific formats, the number itself must be only digits, no ('s, -'s and the like. Is such validation possible without asking user for a country? The trick is that I want to work with all numbers world-wide. I guess it can't be done with regex (googled a bit and found lots of stuff but not for this problem). Is there any library for it? I'm using python. Or maybe it would make more sense to enforce a format e.g. X-YYYYYYYY... where X would be a country code, or something like this?
How to check if phone number entered by user includes country code?
0.132549
0
0
4,020
3,125,325
2010-06-26T19:56:00.000
1
0
0
1
python,android,ase
3,125,831
2
false
1
0
You should use android.exit().
2
2
0
I'm using android scripting environment with python (ASE), and I'd like to terminate the shell executing the script when the script terminates. Is there a good way to do this? I have tried executing on the last line: os.system( 'kill %d' % os.getppid() ) but to no avail.
Terminating android ASE shell from within the script
0.099668
0
0
329
3,125,325
2010-06-26T19:56:00.000
0
0
0
1
python,android,ase
3,304,337
2
false
1
0
My guess is that the above answer ought to be android.Android().exit()
2
2
0
I'm using android scripting environment with python (ASE), and I'd like to terminate the shell executing the script when the script terminates. Is there a good way to do this? I have tried executing on the last line: os.system( 'kill %d' % os.getppid() ) but to no avail.
Terminating android ASE shell from within the script
0
0
0
329
3,125,333
2010-06-26T20:02:00.000
28
0
0
1
python,pylint
3,125,349
1
true
0
0
If I'm not mistaken, you should be able to use --disable-msg-cat=C (can't remember whether it's uppercase or lowercase or both) to accomplish this. UPDATE: In later versions of pylint, you should use --disable=C
1
23
0
Background I find pylint useful, but I also find it is horrifically undocumented, has painfully verbose output, and lacks an intuitive interface. I'd like to use pylint, but it keeps pumping out an absurd number of pointless 'convention' messages, e.g. C: 2: Line too long (137/80) etc. Question If I could disable these, pylint would be much more usable for me. How does one disable these 'convention' messages? My own efforts I've tried putting disable-msg=C301 in ~/.pylintrc (which is being loaded because when I put an error in there pylint complains) which I understand to be the "Line too Long" message based on running this command in the pylint package directory (documentation that can be found would be nice): $ grep "Line too long" **/*.py checkers/format.py: 'C0301': ('Line too long (%s/%s)', Yet this disable-msg does nothing. I'd disable the entire convention category with the disable-msg-cat= command, but there's no indication anywhere I can find of what an identifier of the convention category would be for this command — the intuitive disable-message-cat=convention has no effect. I'd be much obliged for some direction on this issue. Thank you. Brian
Disable all `pylint` 'Convention' messages
1.2
0
0
10,285
3,125,678
2010-06-26T22:15:00.000
0
0
1
0
python
3,125,987
5
false
0
0
you can also set PYTHONINSPECT in your environment
1
2
0
Say I had a Python file, and I wanted to run it in the top level, but after it finishes, I want to pick up where it leaves off. I want to be able to use the objects it creates, etc. A simple example, let's say I have a Python script that does i = 5. When the script ends, I want to be returned to the top level and be able to continue with i = 5.
How to run Python top level/interpreter with file input?
0
0
0
466
3,125,707
2010-06-26T22:25:00.000
0
0
0
0
python,binding,tkinter
3,126,035
1
true
0
1
The terminology which describes what you want is "focus" -- you want to set the keyboard focus to your text widget. To do that you need to use the focus_set() and/or focus_force() methods on the text widget.
1
0
0
In Tkinter I'm trying to make it so when a command is run a widget is automatically selected, so that a one may bind events to the newly selected widget. Basically I want it so when I press a button a text widget appears. When it appears normally one would have to click the text widget to facilitate the running of events bound to the text widget. I want that behavior to automatically happen when the user clicks the button. So that one does not have to click the button and then the text widget, but simply the button. I'd also like it so if one started typing after the button was pressed it would automatically start filling the text widget. Again to cut out having to click on the text widget. What bit of code does the above?
Selecting Widgets
1.2
0
0
45
3,126,155
2010-06-27T02:19:00.000
2
0
0
0
python,sql,mysql,database
3,126,208
4
false
1
0
MySQL is really your best choice for the database unless you want to go proprietary. As for the actual language, pick whatever you are familiar with. While Youtube and Reddit are written in python, many of the other large sites use Ruby (Hulu, Twitter, Techcrunch) or C++ (Google) or PHP (Facebook, Yahoo, etc).
1
4
0
My two main requirements for the site are related to degrees of separation and graph matching (given two graphs, return some kind of similarity score). My first thought was to use MySql to do it, which would probably work out okay for storing how I want to manage 'friends' (similar to Twitter), but I'm thinking if I want to show users results which will make use of graphing algorithms (like shortest path between two people) maybe it isn't the way to go for that. My language of choice for the front end, would be Python using something like Pylons but I haven't committed to anything specific yet and would be willing to budge if it fitted well with a good backend solution. I'm thinking of using MySQL for storing user profile data, neo4j for the graph information of relations between users and then have a Python application talk to both of them. Maybe there is a simpler/more efficient way to do this kind of thing. At the moment for me it's more getting a suitable prototype done than worrying about scalability but I'm willing to invest some time learning something new if it'll save me time rewriting/porting in the future. PS: I'm more of a programmer than a database designer, so I'd prefer having rewrite the frontend later rather than say porting over the database, which is the main reason I'm looking for advice.
What should I use for the backend of a 'social' website?
0.099668
1
0
749
3,126,802
2010-06-27T08:17:00.000
0
0
0
0
python,gtk,pygtk
3,128,879
3
false
0
1
In most recent versions of PyGTK you can get/set those values via table.props.n_columns and table.props.n_rows, which is synonymous with the get_property() (mentioned in the other answers) and set_property() methods.
1
0
0
I am having a problem with widget Gtk.Table - I would like to know, if there is a way how to get a current size of the table (number of rows and columns). Thank you, very much for help, Tomas
Getting size of Gtk.Table in python
0
0
0
881
3,126,969
2010-06-27T09:36:00.000
2
0
0
0
python,django,url,post,django-views
3,127,296
4
true
1
0
A modified option #1 is the best approach. Consider this: suppose we weren't talking about a web app, but instead were just designing an inbox class. Which do you like better, a number of methods (delete_message(), mark_as_spam(), etc), or one big method (do_stuff(action))? Of course you would use the separate methods. A separate URL for each action, each with a separate view, is far preferable. If you don't like the redirect at the end, then don't use it. Instead, have a render_inbox(request) method that returns an HttpResponse, and call the method at the end of each of your views. Of course, redirecting after a POST is a good way to prevent double-actions, and always leaves the user with a consistent URL. Even better might be to use Ajax to hide the actions, but that is more involved.
4
4
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
1.2
0
0
334
3,126,969
2010-06-27T09:36:00.000
1
0
0
0
python,django,url,post,django-views
3,127,290
4
false
1
0
If you're writing a web 2.0 messaging app, you would be using AJAX calls and wouldn't be loading a new page at all. The process would proceed like so: User clicks [delete] for a message. This button has a javascript action bound to it. This action does the following: i. Change the UI to indicate that something is happening (grey the message or put up an hourglass). ii. Send a request to /messages/inbox/1234/delete. (where 1234 is some identifier that indicates which message) iii. When the response from the server comes back, it should indicate success or failure. Reflect this status in the current UI. For example, on success, refresh the inbox view (or just remove the deleted item). On the server side, now you can create a URL handler for each desired action (i.e. /delete, /flag, etc.). If want to use an even more RESTful approach, you would use the HTTP action itself to indicate the action to perform. So instead of including delete in your URL, it would be in the action. So instead of GET or POST, use DELETE /messages/inbox/1234. To set a flag for having been read, use SET /messages/inbox/1234?read=true. I don't know how straightforward it is in Django to implement this latter recommendation, but in general, it's a good idea utilize the protocol (in this case HTTP), rather than work around it by encoding your actions into a URL or parameter.
4
4
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
0.049958
0
0
334
3,126,969
2010-06-27T09:36:00.000
0
0
0
0
python,django,url,post,django-views
3,127,284
4
false
1
0
I agree that #2 is a better approach. But take care with overloading the submit <input /> with different methods -- if a user is using it with keyboard input and hits enter, it won't necessarily submit the <input /> you're expecting. Either disable auto-submit-on-enter, or code things up so that if there is more than one thing that submit can do, there's another field that sets what the action should be (eg a 'delete' checkbox, which is tested during a request.POST) If you went with #1 I'd say that a GET to a POST-only view should be met with a 405 (method not supported) - or, failing that, a 404.
4
4
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
0
0
0
334
3,126,969
2010-06-27T09:36:00.000
1
0
0
0
python,django,url,post,django-views
3,127,022
4
false
1
0
I don't think there's anything wrong with either option, but #2 is potentially better from a performance standpoint. After the action is posted you can render the inbox without a redirect, so it cuts down on the HTTP traffic.
4
4
0
I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message Mark a message as read Report a message as spam With all of those things causing a page refresh, but leading back to the same page. I'm wondering how to design my URLs and views around this. I see (at least) two options, and I have no idea which is more idiomatic. Option 1) Have a separate URL and view for each action. So, /inbox/delete-message/ maps to views.delete_message, and so on. At the end of each of those views, it redirects back to /inbox/. I like the way things are clearly separated with this option. If a user somehow finds themselves sending a GET request to /inbox/delete-message/, that presents a sort of weird situation though (do I throw up an error page? silently redirect them?). Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?
URLs and side effects (Django)
0.049958
0
0
334
3,127,467
2010-06-27T13:26:00.000
2
0
0
0
python,c,sockets,serialization
3,127,588
1
false
0
0
I think you answered your own question. JSON is certainly a good choice. It's also not terribly difficult to do your own serialization in C.
1
1
0
I have a C program and a Python program on the same machine. The C program generates some data in nested structures. What form of IPC is the best way to get this data across to the python program? Serializing in C (especially nested structures) is a real bear, from what I hear, due to lack of serialization libraries. I am not very familiar with shared memory, but I assume the formatting of the C structures may not be very palatable to the python program when it comes to memory alignment and following pointers. The ctype and struct library seems to be for non-nested structures only. So far, what I am thinking is: Wrap all the data in the C program into some xml or json format, write it via socket to python program and then let python program interpret the xml/json formatted data. Looks very cumbersome with lots of overheads. Any better ideas ?
Sending binary data over IPC from C to Python
0.379949
0
1
766
3,127,715
2010-06-27T14:49:00.000
5
0
1
1
python,linux,python-3.x
7,409,203
6
false
0
0
All of them have the repositories, but if you care for one that has python3 as default, I only know of ArchLinux.
4
6
0
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
0.16514
0
0
5,178
3,127,715
2010-06-27T14:49:00.000
2
0
1
1
python,linux,python-3.x
3,128,073
6
false
0
0
I think most distros have it. Debian has it so all derived distros (Ubuntu et. all) do. Fedora as well. It's just that it's not used for the standard system utilities so just typing python will give you a 2.x interpreter.
4
6
0
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
0.066568
0
0
5,178
3,127,715
2010-06-27T14:49:00.000
1
0
1
1
python,linux,python-3.x
3,129,338
6
false
0
0
Gentoo has Python3 (I have 2.6.4-r1 and 3.1.2-r3 installed, 2.6 being the default). A quick search reveals that ebuilds of python libraries tested on both 2.x and 3.x have already been built for both versions on my machine (thank God for python-updater, obviously). Gentoo + Python developing is a very nice combination (if you do like the way Gentoo works, that is).
4
6
0
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
0.033321
0
0
5,178
3,127,715
2010-06-27T14:49:00.000
11
0
1
1
python,linux,python-3.x
3,127,755
6
true
0
0
Ubuntu 10.04 comes by default w/ Python 2.6.5, but the following python 3 packages are in the standard repositories as well: python3 python3.1-minimal python3-dev python3.0 python3.1-profiler python3-doc python3.1 python3.1-tk python3-examples python3.1-celementtree python3.1-wsgiref python3-gdbm python3.1-cjkcodecs python3.2 python3-gdbm-dbg python3.1-ctypes python3-all python3-minimal python3.1-dbg python3-all-dbg python3-pkg-resources python3.1-dev python3-all-dev python3-profiler python3.1-doc python3-bsddb python3-setuptools python3.1-elementtree python3-bsddb3 python3-tk python3.1-examples python3-bsddb3-dbg python3-tk-dbg python3.1-gdbm python3-dbg update: for *ubuntu 11.04 the list is (as expected) a bit longer) note that I left out the python3.1- and python3.2- prefixed packages): python3-all python3-examples python3-pkg-resources python3-all-dbg python3-gdbm python3-profiler python3-all-dev python3-gdbm-dbg python3-pygments python3-apt python3-gearman.libgearman python3-pyudev python3-apt-dbg python3-httplib2 python3-serial python3-beaker python3-ipaddr python3-setuptools python3-bsddb3 python3-jinja2 python3-sip python3-bsddb3-dbg python3-jinja2-dbg python3-sip-dbg python3-cxx python3-lxml python3-sip-dev python3-cxx-dev python3-lxml-dbg python3-sqlalchemy python3-dbg python3-mako python3-tk python3-dev python3-markupsafe python3-tk-dbg python3-distutils-extra python3-markupsafe-dbg python3-yaml python3-dns python3-minimal python3-yaml-dbg python3-doc python3-objgraph python3-zope.fixers UPDATE (2013-03-21): The current version of *buntu (12.10) already has fairly many Python 3 packages available (>200; too many to list). Prominent exceptions include python3-django and python3-matplotlib (though the latter will be included in 13.04 Raring Ringtail). If you require a package not yet in the package manager but already ported, 12.10 includes both pip and easy_install for Python 3.
4
6
0
I would like to know if there is any Linux distribution where you can easily install and use Python 3. This means a distribution that will provide not only Python 3 binaries and updates but also python modules. I know that probably we are not going to see any python 3 as the default python interpretor so soon but at least I would like to see latest 2.x as default (2.6+) one and the alternative one already installed. Probably it is a question between major distributions: Ubuntu, Fedora or Suse?
Is there any linux distribution that comes with python 3?
1.2
0
0
5,178
3,127,915
2010-06-27T16:07:00.000
0
0
1
1
python,google-app-engine
3,130,801
3
false
1
0
OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer: 1) Install Python 2.5. 2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default. 3) Install the Google App Engine SDK. 4) Launch, "Google App Engine Launcher" from the Start Menu 5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe
2
4
0
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Is it possible to run two versions of Python side-by-side?
0
0
0
758
3,127,915
2010-06-27T16:07:00.000
5
0
1
1
python,google-app-engine
3,127,950
3
false
1
0
Absolutely. If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course. Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.) Windows users generally just install to different directories.
2
4
0
I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Is it possible to run two versions of Python side-by-side?
0.321513
0
0
758
3,127,984
2010-06-27T16:30:00.000
5
0
0
0
python,html,xml
3,127,997
3
false
1
0
XML (and XHTML) tags are case-sensitive ... so <this> and <tHis> would be different elements. However a lot (rough estimate) of HTML (not XHTML) tags are random-case.
3
1
0
If you are parsing html or xml (with python), and looking for certain tags, it can hurt performance to lower or uppercase an entire document so that your comparisons are accurate. What percentage (estimated) of xml and html docs use any upper case characters in their tags?
When matching html or xml tags, should one worry about casing?
0.321513
0
1
98
3,127,984
2010-06-27T16:30:00.000
2
0
0
0
python,html,xml
3,128,006
3
false
1
0
Only if you're using XHTML as this is case sensitive, whereas HTML is not so you can ignore case differences. Test for the doctype before worrying about checking for case.
3
1
0
If you are parsing html or xml (with python), and looking for certain tags, it can hurt performance to lower or uppercase an entire document so that your comparisons are accurate. What percentage (estimated) of xml and html docs use any upper case characters in their tags?
When matching html or xml tags, should one worry about casing?
0.132549
0
1
98
3,127,984
2010-06-27T16:30:00.000
1
0
0
0
python,html,xml
3,128,078
3
true
1
0
I think you're overly concerned about performance. If you're talking about arbitrary web pages, 90% of them will be HTML, not XHTML, so you should do case-insensitive comparisons. Lowercasing a string is extremely fast, and should be less than 1% of the total time of your parser. If you're not sure, carefully time your parser on a document that's already all lowercase, with and without the lowercase conversions. Even a pure-Python implementation of lower() would be negligible compared to the rest of the parsing, but it's better than that - CPython implements lower() in C code, so it really is as fast as possible. Remember, premature optimization is the root of all evil. Make your program correct first, then make it fast.
3
1
0
If you are parsing html or xml (with python), and looking for certain tags, it can hurt performance to lower or uppercase an entire document so that your comparisons are accurate. What percentage (estimated) of xml and html docs use any upper case characters in their tags?
When matching html or xml tags, should one worry about casing?
1.2
0
1
98
3,128,025
2010-06-27T16:41:00.000
0
1
0
1
python,twisted,logging,irc
3,128,285
2
false
0
0
I don't think you can do this if you just connect to a server... the servers don't send you messages for channels you haven't joined. Or are you the host of the server?
2
0
0
I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages/commands/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?
How to Log All IRC data on Channel Using Twisted?
0
0
0
617
3,128,025
2010-06-27T16:41:00.000
1
1
0
1
python,twisted,logging,irc
5,207,277
2
true
0
0
We addressed this issue in a somewhat round about way. We worked off a generic hexdumping proxy server constructed in twisted and then created finer detail parsing algorithms off of that.
2
0
0
I have a somewhat unique request. What I am looking to do is listen on a specific port for all traffic coming through via IRC protocol. I then want to log all of those messages/commands/ect. I do not, however, want to join the channel. I just want to listen and log. Is there an easy built in way to do this? I have been looking at the irc.IRC and irc.IRCClient classes in twisted but they both seem too high level to do this. Is the only way to do this to simply descend to the base Server class, or can I still leverage some of the higher level functionality of twisted?
How to Log All IRC data on Channel Using Twisted?
1.2
0
0
617
3,129,633
2010-06-28T01:36:00.000
0
0
0
0
python,model,mvp,three-tier
3,136,965
3
false
1
0
I think the main differences is that in MVP/MVC, the view gets to reach into the model to get data, while in n-tier, there's a stricter separation, where each tier is only allowed to interface with the tier directly above/below it.
3
2
0
What is the difference between the two architectures: Model-View-Presenter and Three-Tier? I understand the definitions of each when read individually, but I can't readily see how they're different. Is it desktop vs web? I am currently developing a simple desktop application in Python to visualize a complicated data model via a GUI. Thanks!
Model-View-Presenter and Three-Tier?
0
0
0
1,009
3,129,633
2010-06-28T01:36:00.000
4
0
0
0
python,model,mvp,three-tier
3,137,005
3
true
1
0
MVC is an UI pattern, three tier is an application architecture pattern. That is you can design your application with 3 tiers - UI, BL, data. And than use MVC in the UI tier.
3
2
0
What is the difference between the two architectures: Model-View-Presenter and Three-Tier? I understand the definitions of each when read individually, but I can't readily see how they're different. Is it desktop vs web? I am currently developing a simple desktop application in Python to visualize a complicated data model via a GUI. Thanks!
Model-View-Presenter and Three-Tier?
1.2
0
0
1,009
3,129,633
2010-06-28T01:36:00.000
1
0
0
0
python,model,mvp,three-tier
8,291,398
3
false
1
0
MVC is a UI implementation pattern that attempts to simplify three tier architecture. MVC is just one of the ways you can implement three-tier.
3
2
0
What is the difference between the two architectures: Model-View-Presenter and Three-Tier? I understand the definitions of each when read individually, but I can't readily see how they're different. Is it desktop vs web? I am currently developing a simple desktop application in Python to visualize a complicated data model via a GUI. Thanks!
Model-View-Presenter and Three-Tier?
0.066568
0
0
1,009
3,130,172
2010-06-28T05:04:00.000
3
0
1
0
python,oop
3,130,233
2
true
0
0
Most ORMs handles this. Just use an in-memory SQLite table, and let it do the hard work.
1
2
0
Consider the following hypothetical people management system. Suppose each Person object belong to a number of Group objects and each Group contains a number of Person objects. We could represent it by adding a list to each Person and each Group object, but then we have to keep this in sync when we create, delete or modify an object. On change callbacks won't work well in this situation as they could lead to an infinite loop. Now suppose each Group has a name and a description. The name is stored in a dict so that we can find which group uses which name and the description is indexed so that we can search it. These need to be updated whenever a group changes. The application has a GUI which can display the Person and Group. Whenever a property of the object changes, the GUI needs to update. Suppose we have to deal with a large number of effects like this. Keeping track of this is rather confusing. I could imagine these using properties, custom collections or maybe even metaclasses. Are there any design patterns/frameworks for dealing with these kind of systems?
Maintaining relationships between objects in Python
1.2
0
0
150
3,130,275
2010-06-28T05:35:00.000
4
0
1
0
python
3,130,291
4
true
0
0
A copy of the string is not put into both, they just both point to the one string.
1
3
0
For instance if you add the same string to a dict and a list?
If you add the same string to two different lists or collections in Python, are you using twice the memory?
1.2
0
0
126
3,130,923
2010-06-28T08:17:00.000
0
0
0
0
python,urllib2,urllib
3,131,037
2
false
0
0
Modifying parts of a library is never a good idea. You can write wrappers around the methods you use to fetch data that would provide the desired behavior. Which would be trivial. You can for example define methods with the same names as in urllib2 in your own module called myurllib2. Then just change the imports everywhere you use urllib2
1
2
0
My Python application makes a lot of HTTP requests using the urllib2 module. This application might be used over very unreliable networks where latencies could be low and dropped packets and network timeouts might be very common. Is is possible to override a part of the urllib2 module so that each request is retried an X number of times before raising any exceptions? Has anyone seen something like this? Can i achieve this without modifying my whole application and just creating a wrapper over the urllib2 module. Thus any code making requests using this module automatically gets to use the retry functionality. Thanks.
Make urllib retry multiple times
0
0
1
6,335
3,131,217
2010-06-28T09:15:00.000
5
0
1
0
python,error-handling,module,cross-platform
3,131,261
3
false
0
0
The easiest way is to ensure that all modules can be loaded on all systems. If that doesn't work, enclosing each import statement in a try block is the next best solution and not un-Pythonic at all.
1
54
0
This probably has an obvious answer, but I'm a beginner. I've got a "module" (really just a file with a bunch of functions I often use) at the beginning of which I import a number of other modules. Because I work on many systems, however, not all modules may be able to load on any particular machine. To make things slightly more difficult, I also change the names of the packages when I import them -- for example, matplotlib gets abbreviated to mp. What I'd like to do is only load those modules that exist on the system I'm currently using, and do some error handling on the ones that don't. The only way I can think of doing so is by enclosing each import statement inside its own try block, which seems pretty un-pythonic. If I enclose them all in the same try block, whichever module throws an error will prevent the subsequent modules from being loaded. Any ideas that might make things look prettier? It would be so easy if I didn't want to change their names...
Error handling when importing modules
0.321513
0
0
78,900
3,131,703
2010-06-28T10:46:00.000
7
1
1
0
c#,architecture,ironpython
3,131,716
2
false
0
1
One of IronPython's key advantages is in its function as an extensibility layer to application frameworks written in a .NET language. It is relatively simple to integrate an IronPython interpreter into an existing .NET application framework. Once in place, downstream developers can use scripts written in IronPython that interact with .NET objects in the framework, thereby extending the functionality in the framework's interface, without having to change any of the framework's code base. IronPython makes extensive use of reflection. When passed in a reference to a .NET object, it will automatically import the types and methods available to that object. This results in a highly intuitive experience when working with .NET objects from within an IronPython script. Source - Wikipedia
2
2
0
We all knows that C# is a static language while Python is a dynamic language. But I want to know what are the features that Python has and c# does not. Also, is it advisable/beneficial to use IronPython with c# in the same application? Also what points I should focus to learn before I try to convince my boss to use IronPython?
Why should C# developer learn IronPython?
1
0
0
995
3,131,703
2010-06-28T10:46:00.000
7
1
1
0
c#,architecture,ironpython
3,131,741
2
true
0
1
In other words, what points I can give to my boss to convince him to use IronPython? Don't. If you don't know why you should use a new tool and for what, don't try to convice anybody to use it. At work, you should try to solve problems with the best tools for the task, not throw the fanciest tools avaiable at your problems just because they're fancy. Learn IronPython, maybe make a small side project in it, find out what the strenghts are. Then if you think these strengths are useful for the project you're working on (e.g. for "glue code", plugins, macros etc.), convice your boss to use them.
2
2
0
We all knows that C# is a static language while Python is a dynamic language. But I want to know what are the features that Python has and c# does not. Also, is it advisable/beneficial to use IronPython with c# in the same application? Also what points I should focus to learn before I try to convince my boss to use IronPython?
Why should C# developer learn IronPython?
1.2
0
0
995
3,131,977
2010-06-28T11:38:00.000
0
0
0
1
python,c,printf,ctypes
3,133,108
2
false
0
0
Well printf simply writes its output to whatever the stdout file pointer refers to. Im not sure how you're executing the C program, but it should be possible to redirect the C program's stdout to something that you can read in Python.
1
5
0
I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this? Thanks
How to 'catch' c printf in python with ctypes?
0
0
0
2,287
3,132,265
2010-06-28T12:20:00.000
49
0
1
1
python,python-idle
3,132,305
5
false
0
0
just use Alt+P to go up. Similarly, Alt+N could be used to go down.
2
114
0
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result. But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied? Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?
How do I access the command history from IDLE?
1
0
0
75,492
3,132,265
2010-06-28T12:20:00.000
12
0
1
1
python,python-idle
26,785,641
5
false
0
0
If you're on mac, it's ctrl+p.
2
114
0
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result. But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied? Or use the mouse to pinpoint that line and click there, and press ENTER to copy? Is there a faster way?
How do I access the command history from IDLE?
1
0
0
75,492
3,133,690
2010-06-28T15:22:00.000
0
0
1
1
python,windows,environment-variables
3,165,062
3
false
0
0
I believe your call should be: import sys os.system(sys.executable+ ' second.py') So that you guarantee you're using the same interpreter you're currently running and not launching the other one (or did you really mean to use the other interpreter?)
2
2
0
The story began with a very strange error while I was running my script from PyDev. Running the same script from outside will not encounter the same problem. Fatal Python error: Py_Initialize: can't initialize sys standard streams File "C:\Python26\lib\encodings\__init__.py", line 123 raise CodecRegistryError,\ ^ SyntaxError: invalid syntax This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I was able to find why this is happening: In PyDev I use two different Python versions: 3.1 that is the default installation and 2.6 as the alternative one. My Windows Environment does not contains PYTHONHOME, CLASSPATH, PYTHONPATH but PyDev does add them. Now the problem is at one stage my python script does execute another python script using os.system(python second.py) and the second script will fail with the above error. Now I'm looking to find a way to prevent this issue, issue that is happening because it will run the execute the default python using the settings for the non-default one (added by PyDev). I do not want to change the standard call (python file.py) but I want to be able to run my script from pydev without problem and being able to use default or alternative python environment. Any ideas?
How to properly use PyDev with two different Python versions with scripts that are recalling other python scripts?
0
0
0
1,364
3,133,690
2010-06-28T15:22:00.000
2
0
1
1
python,windows,environment-variables
3,133,843
3
true
0
0
I found a solution that seams acceptable specially because it will not interfere with running the scripts on other systems, just to run python -E second.py - this will force Python to ignore PYTHON* environment variables.
2
2
0
The story began with a very strange error while I was running my script from PyDev. Running the same script from outside will not encounter the same problem. Fatal Python error: Py_Initialize: can't initialize sys standard streams File "C:\Python26\lib\encodings\__init__.py", line 123 raise CodecRegistryError,\ ^ SyntaxError: invalid syntax This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. I was able to find why this is happening: In PyDev I use two different Python versions: 3.1 that is the default installation and 2.6 as the alternative one. My Windows Environment does not contains PYTHONHOME, CLASSPATH, PYTHONPATH but PyDev does add them. Now the problem is at one stage my python script does execute another python script using os.system(python second.py) and the second script will fail with the above error. Now I'm looking to find a way to prevent this issue, issue that is happening because it will run the execute the default python using the settings for the non-default one (added by PyDev). I do not want to change the standard call (python file.py) but I want to be able to run my script from pydev without problem and being able to use default or alternative python environment. Any ideas?
How to properly use PyDev with two different Python versions with scripts that are recalling other python scripts?
1.2
0
0
1,364
3,134,332
2010-06-28T16:43:00.000
1
0
0
1
python,osx-snow-leopard,numpy,macports
3,134,369
3
false
0
0
You need to update your PATH so that the stuff from MacPorts is in front of the standard system directories, e.g., export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/:$PATH. UPDATE: Pay special attention to the fact that /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin is in front of your old PATH value.
1
1
1
I have a MacBook Pro with Snow Leopard, and the Python 2.6 distribution that comes standard. Numpy does not work properly on it. Loadtxt gives errors of the filename being too long, and getfromtxt does not work at all (no object in module error). So then I tried downloading the py26-numpy port on MacPorts. Of course when I use python, it defaults the mac distribution. How can I switch it to use the latest and greatest from MacPorts. This seems so much simpler than building all the tools I need from source... Thanks!
Switch python distributions
0.066568
0
0
645
3,134,531
2010-06-28T17:12:00.000
13
1
1
0
php,python,oop,interface
3,134,623
9
false
0
0
First, and foremost, try not to compare and contrast between Python and Java. They are different languages, with different semantics. Compare and contrast will only lead to confusing questions like this where you're trying to compare something Python doesn't use with something Java requires. It's a lot like comparing the number 7 and the color green. They're both nouns. Beyond that, you're going to have trouble comparing the two. Here's the bottom line. Python does not need interfaces. Java requires them. Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well? The two concepts have almost nothing to do with each other. I can define a large number of classes which share a common interface. In Python, because of "duck typing", I don't have to carefully be sure they all have a common superclass. An interface is a declaration of "intent" for disjoint class hierarchies. It provides a common specification (that can be checked by the compiler) that is not part of the simple class hierarchy. It allows multiple class hierarchies to implement some common features and be polymorphic with respect to those features. In Python you can use multiple inheritance with our without interfaces. Multiple inheritance can include interface classes or not include interface classes. Java doesn't even have multiple inheritance. Instead it uses a completely different technique called "mixins". Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I can just check if a method exists in an object in Python, that inherits from multiple classes? If you create an interface in Python, it can be a kind of formal contract. A claim that all subclasses will absolutely do what the interface claims. Of course, a numbskull is perfectly free to lie. They can inherit from an interface and mis-implement everything. Nothing prevents bad behavior from sociopaths. You create an interface in Java to allow multiple classes of objects to have a common behavior. Since you don't tell the compiler much in Python, the concept doesn't even apply. Do Interfaces were created in another languages because they don't provide multiple inheritance? Since the concepts aren't related, it's hard to answer this. In Java, they do use "mixin" instead of multiple inheritance. The "interface" allows some mixing-in of additional functionality. That's one use for an interface. Another use of an Interface to separate "is" from "does". The class hierarchy defines what an objects IS. The interface hierarchy defines what a class DOES. In most cases, IS and DOES are isomorphic, so there's no distinction. In some cases, what an object IS and what an object DOES are different.
3
9
0
I've been playing mostly with PHP and Python. I've been reading about Interfaces in OO programming and can't see an advantage in using it. Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well? Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I can just check if a method exists in an object in Python, that inherits from multiple classes? Do Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?
Are Interfaces just "Syntactic Sugar"?
1
0
0
1,276
3,134,531
2010-06-28T17:12:00.000
5
1
1
0
php,python,oop,interface
3,134,569
9
false
0
0
Even in duck-typed languages like Python, an interface can be a clearer statement of your intent. If you have a number of implementations, and they share a set of methods, an interface can be a good way to document the external behavior of those methods, give the concept a name, and make the concept concrete. Without the explicit interface, there's an important concept in your system that has no physical representation. This doesn't mean you have to use interfaces, but interfaces provide that concreteness.
3
9
0
I've been playing mostly with PHP and Python. I've been reading about Interfaces in OO programming and can't see an advantage in using it. Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well? Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I can just check if a method exists in an object in Python, that inherits from multiple classes? Do Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?
Are Interfaces just "Syntactic Sugar"?
0.110656
0
0
1,276
3,134,531
2010-06-28T17:12:00.000
0
1
1
0
php,python,oop,interface
3,134,554
9
false
0
0
It's generally implemented to replace multiple inheritance (C#). I think some languages/programmers use them as a way of enforcing requirements for object structure as well.
3
9
0
I've been playing mostly with PHP and Python. I've been reading about Interfaces in OO programming and can't see an advantage in using it. Multiple objects can implement the same interface, but multiple inheritance doesn't provide this as well? Why do I need to create an Interface "with no implementation" - mainly a "contract" - if I can just check if a method exists in an object in Python, that inherits from multiple classes? Do Interfaces were created in another languages because they don't provide multiple inheritance? Or am I missing something more important here?
Are Interfaces just "Syntactic Sugar"?
0
0
0
1,276
3,134,699
2010-06-28T17:33:00.000
3
0
0
0
python,sql,postgresql,pygresql
3,137,124
1
true
0
0
Use Psycopg 2. It correctly converts between Postgres's interval data type and Python's timedelta.
1
0
0
With PostgreSQL, one of my tables has an 'interval' column, values of which I would like to extract as something I can manipulate (datetime.timedelta?); however I am using PyGreSQL which seems to be returning intervals as strings, which is less than helpful. Where should I be looking to either parse the interval or make PyGreSQL return it as a <something useful>?
python sql interval
1.2
1
0
1,424
3,134,850
2010-06-28T17:54:00.000
1
0
0
0
python,django
3,135,033
2
false
1
0
headline__contains='%' would mean headline is anything, no? In which case why include it in the query?
1
1
0
I want to be able to use wildcards in my django queries used for searching. However as the documentation says: Entry.objects.filter(headline__contains='%') Will result in SQL that looks something like this: SELECT ... WHERE headline LIKE '%\%%'; How do I tell django to not escape % and _ in a query. Or is there another way to implement wildcard search in django (apart from writing the sql directly)?
How do I tell django to not escape % and _ in a query
0.099668
0
0
1,005
3,136,131
2010-06-28T21:07:00.000
0
0
0
0
python,ruby-on-rails,django
3,136,189
3
false
1
0
I interviewed for a Rails job once. I had almost no experience in Rails, although I had a fair amount of experience with Python and Django. I told the interviewer this up front, and I still got through several rounds of interviews, since the technical guys figured I could pick up the Rails stuff easily enough. (Ultimately I didn't get the job. Ah, well.) But it probably depends on who is interviewing you. Some people might see the experience as comparable, others might not.
2
3
0
I ask this because there seems to be a few more jobs available (at least by telecommute) in RoR. If an employer sees significant Python/Django experience on a resume, would it be plausible to believe that the developer would be able quickly learn Rails?
Is Python (Django) experience professionaly comparable to Ruby on Rails?
0
0
0
458
3,136,131
2010-06-28T21:07:00.000
0
0
0
0
python,ruby-on-rails,django
3,136,175
3
false
1
0
I can't speak for all organizations, but as a hiring manager where I work, yes. I am really interested in experience with MVC in general. The specific technology / framework doesn't concern me as much as the fact that you understand what a model/view/controller framework is good for, and when to use it. That said, if I see RoR and Python/Django, I'm probably going to pigeon-hole you as a front-end developer and push you towards the web apps division as opposed to our infrastructure division.
2
3
0
I ask this because there seems to be a few more jobs available (at least by telecommute) in RoR. If an employer sees significant Python/Django experience on a resume, would it be plausible to believe that the developer would be able quickly learn Rails?
Is Python (Django) experience professionaly comparable to Ruby on Rails?
0
0
0
458
3,136,423
2010-06-28T21:52:00.000
0
0
1
0
python,django
3,139,071
3
false
1
0
Just "throw" the django tarball within the site-packages (dist-packages in py2.6+) and you are done. What for do you need macports etc, with a pure python library?
1
2
0
I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again.....
Trying to install Django via Macports on Leopard
0
0
0
936
3,136,997
2010-06-28T23:58:00.000
0
0
0
0
python,model-view-controller,wxpython,dry,wxwidgets
3,137,378
2
true
0
1
More in response to your comment to Jon Cage's answer, than to your original question (which was perfectly answered by Jon): The user might find it irritating, if the position of every element in your dialog changes, when he makes a choice. Maybe it'll look better, if only the "variable part" is updated. To achieve this, you could make a panel for each set of additional controls. The minimum size of each panel should be the minimum size of the largest of these panels. Depending on the user's choice you can hide or show the desired panel. Alternatively, wxChoicebook might be what you need?
1
1
0
I have a wxPython application which allows the users to select items from menus that then change what is visible on the screen. This often requires a recalculation of the layout of panels. I'd like to be able to call the layout of all the children of a panel (and the children of those children) in reverse order. That is, the items with no children have their Layout() function called first, then their parents, and so on. Otherwise I have to keep all kinds of knowledge about the parents of panels in the codes. (i.e. how many parents will be affected by a change in this-or-that panel).
How to layout all children of a wxPanel?
1.2
0
0
248
3,137,167
2010-06-29T00:56:00.000
1
0
0
0
python
3,137,299
1
false
1
0
I think the best way would be through CSS. You can handle it by adding the pseudoclass :active to the CSS. Other way is serving the page with a new class added to the tab, which will change the background color, but I would not recommend that.
1
0
0
I am trying to develop my first python web project. It have multiple tabs (like apple.com have Store, iPhone, iPad etc tabs) and when user click on any tab, the page is served from server. I want to make sure that the selected tab will have different background color when page is loaded. Which is a best way to do it? JavaScript/CSS/Directly from server? and How? Thanks.
Highlight selected Tab - Python webpage
0.197375
0
1
149
3,138,677
2010-06-29T07:26:00.000
7
0
0
0
python,eclipse,pydev
3,141,573
1
true
0
0
To the left of the down arrow is the "Setup custom filters" button. You can enter custom filters delimited by commas. If that file name indeed has a comma in it, then you will have to enter the filter as *cover since *,cover is treated as two separate filters.
1
4
0
If you click on the icon resembling a downard-pointing triangle in the PyDev Package Explorer and then select "Customize View", The "Available Customizations" pop-down allows the user to select which of a standard set of files are visible in the package explorer. That's great if you wish to exlude or include certain standard types of file from the view, however I'd like to exclude a type which is currently unknown to PyDev. In this case, I'd like to exclude "*,cover" - that's any automatically generated coverage report file. PyDev creates these files any time you try to run a coverage analysis but does not seem to have a way of excluding these files from the views. I'd love to hide all the ",cover" files in order to reduce the clutter in my package explorer.
In Eclipse PyDev is there a way to exclude arbitrary file-types from the Pydev Package explorer?
1.2
0
0
962
3,139,372
2010-06-29T09:23:00.000
1
0
1
0
python,django
3,139,638
2
false
1
0
Django is 100% compatible with Python 2.4. However if you really want to use 2.5 you would probably be best off using a virtualenv and installing Django and your project inside that. Don't forget if you do try and install 2.5, you will also need to recompile mod_wsgi to use it, as the system packaged version will only use 2.4.
1
2
0
I have to install Django on my linux server where python 2.4 is available as the default installation. I have installed python 2.5 as a separate version. Now I have to install Django which I have to use with python 2.5. Is there any specific requirement, so that it is installed with the python 2.5 and not with the default 2.4 version available on the server ? Please suggest. Thanks in advance.
Installing django with python 2.5 and not with the default version of python
0.099668
0
0
400