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,397,850
2010-08-03T15:05:00.000
0
0
0
0
python,testing,black-box
3,397,887
4
false
1
0
What exactly is "Testing links"? If it means they lead to non-4xx URIs, I'm afraid You must visit them. As for existence of given links (like "Contact"), You may look for them using xpath.
2
2
0
I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. So my question is can i verify the links in a loop or i need to try every link on my own? i trie...
how can i verify all links on a page as a black-box tester
0
0
1
412
3,397,850
2010-08-03T15:05:00.000
0
0
0
0
python,testing,black-box
3,399,490
4
false
1
0
You could (as yet another alternative), use BeautifulSoup to parse the links on your page and try to retrieve them via urllib2.
2
2
0
I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. So my question is can i verify the links in a loop or i need to try every link on my own? i trie...
how can i verify all links on a page as a black-box tester
0
0
1
412
3,399,185
2010-08-03T17:48:00.000
0
0
0
0
python,twisted.web
3,400,337
1
false
0
0
Well, it doesn't look like you've missed anything. client.getPage doesn't directly support setting the bind address. I'm just guessing here but I would suspect it's one of those cases where it just never occured to the original developer that someone would want to specify the bind address. Even though there isn't buil...
1
0
0
For the past 10 hours I've been trying to accomplish this: Translation of my blocking httpclient using standard lib... Into a twisted nonblocking/async version of it. 10 hours later... scoring through their APIs-- it appears no one has EVER needed to do be able to do that. Nice framework, but seems ...a bit overwhelmi...
Overloading twisted.client.getPage to set the client socket's bindaddress !
0
0
1
314
3,399,367
2010-08-03T18:06:00.000
1
1
1
0
python,ruby-on-rails
3,399,696
6
false
1
0
Even if Ruby/Python interpreters were perfect, and could utilize all avail CPU with single process, you would still reach maximal capability of single server sooner or later and have to scale across several machines, going back to running several instances of your app.
5
1
0
Is it just me or is having to run multiple instances of a web server to scale a hack? Am I wrong in this? Clarification I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
having to run multiple instances of a web service for ruby/python seems like a hack to me
0.033321
0
0
584
3,399,367
2010-08-03T18:06:00.000
1
1
1
0
python,ruby-on-rails
3,399,437
6
false
1
0
With no details, it is very difficult to see what you are getting at. That being said, it is quite possible that you are simply not using the right approach for your problem. Sometimes multiple separate instances are better. Sometimes, your Python services are actually better deployed behind a single Apache instance (u...
5
1
0
Is it just me or is having to run multiple instances of a web server to scale a hack? Am I wrong in this? Clarification I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
having to run multiple instances of a web service for ruby/python seems like a hack to me
0.033321
0
0
584
3,399,367
2010-08-03T18:06:00.000
0
1
1
0
python,ruby-on-rails
3,402,337
6
false
1
0
Your assumption that Tomcat's and IIS's single process per server is superior is flawed. The choice of a multi-threaded server and a multi-process server depends on a lot of variables. One main thing is the underlying operating system. Unix systems have always had great support for multi-processing because of the cop...
5
1
0
Is it just me or is having to run multiple instances of a web server to scale a hack? Am I wrong in this? Clarification I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
having to run multiple instances of a web service for ruby/python seems like a hack to me
0
0
0
584
3,399,367
2010-08-03T18:06:00.000
4
1
1
0
python,ruby-on-rails
3,399,409
6
true
1
0
Not really, people were running multiple frontends across a cluster of servers before multicore cpus became widespread So there has been all the infrastructure for supporting sessions properly across multiple frontends for quite some time before it became really advantageous to run a bunch of threads on one machine. In...
5
1
0
Is it just me or is having to run multiple instances of a web server to scale a hack? Am I wrong in this? Clarification I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
having to run multiple instances of a web service for ruby/python seems like a hack to me
1.2
0
0
584
3,399,367
2010-08-03T18:06:00.000
4
1
1
0
python,ruby-on-rails
3,399,416
6
false
1
0
Since we are now moving towards more cores, rather than faster processors - in order to scale more and more, you will need to be running more instances. So yes, I reckon you are wrong. This does not by any means condone brain-dead programming with the excuse that you can just scale it horizontally, that just seems re...
5
1
0
Is it just me or is having to run multiple instances of a web server to scale a hack? Am I wrong in this? Clarification I am referring to how I read people run multiple instances of a web service on a single server. I am not talking about a cluster of servers.
having to run multiple instances of a web service for ruby/python seems like a hack to me
0.132549
0
0
584
3,400,381
2010-08-03T20:08:00.000
5
0
0
1
python,linux,shell,command-line
3,400,402
6
false
0
0
You want a shebang. #!/path/to/python. Put that on the first line of your python script. The #! is actually a magic number that tells the operating system to interpret the file as a script for the program named. You can supply /usr/bin/python or, to be more portable, /usr/bin/env python which calls the /usr/bin/env pro...
2
12
0
Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible? Info: I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap arg...
Calling a python script from command line without typing "python" first
0.16514
0
0
14,699
3,400,381
2010-08-03T20:08:00.000
4
0
0
1
python,linux,shell,command-line
3,400,404
6
false
0
0
Assuming this is on a unix system, you can add a "shebang" on the top of the file like this: #!/usr/bin/env python And then set the executable flag like this: chmod +x SQLsap
2
12
0
Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible? Info: I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap arg...
Calling a python script from command line without typing "python" first
0.132549
0
0
14,699
3,400,622
2010-08-03T20:44:00.000
2
0
0
0
python,windows,keyboard-shortcuts,tkinter
3,401,235
1
true
0
1
Put return 'break' at the end of your event handling function. This tells Tkinter not to propagate the event to default handlers.
1
0
0
I'd like to implement my own key command. However when I do, it does both what I tell it and the default command. How do I disable the default command, so that my command is the only one that runs? This is on Windows 7, BTW.
How do I disable default Tkinter key commands?
1.2
0
0
226
3,400,847
2010-08-03T21:23:00.000
0
1
1
0
python
3,401,173
6
false
0
0
Seems like what you want is to organize various dependencies between components. You will be better off expressing these dependencies in an object-oriented manner. Rather than doing it by importing modules and global states, encode these states in objects and pass those around. Read up on objects and classes and how to...
4
3
0
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE. instead of running everything from one file, I wanted to organize stuff in modules so I had: main.py callback.py helper.py I ran into problems when I realized that helper.py needed to reference variables from main, but main was ...
A python module for global parameters - is this good practice?
0
0
0
260
3,400,847
2010-08-03T21:23:00.000
1
1
1
0
python
3,401,021
6
true
0
0
I try to design my code so that it looks much like a pyramid. That, I have found, leads to cleaner code.
4
3
0
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE. instead of running everything from one file, I wanted to organize stuff in modules so I had: main.py callback.py helper.py I ran into problems when I realized that helper.py needed to reference variables from main, but main was ...
A python module for global parameters - is this good practice?
1.2
0
0
260
3,400,847
2010-08-03T21:23:00.000
3
1
1
0
python
3,400,902
6
false
0
0
Separate 'global' files for constants, configurations, and includes needed everywhere are fine. But when they contain actual mutable variables then they're not such a good idea. Consider having the files communicate with function return values and arguments instead. This promotes encapsulation and will keep your code f...
4
3
0
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE. instead of running everything from one file, I wanted to organize stuff in modules so I had: main.py callback.py helper.py I ran into problems when I realized that helper.py needed to reference variables from main, but main was ...
A python module for global parameters - is this good practice?
0.099668
0
0
260
3,400,847
2010-08-03T21:23:00.000
2
1
1
0
python
3,400,871
6
false
0
0
Uhm, i think it does not make sence if this happens: "realized that helper.py needed to reference variables from main", your helper functions should be independent from your "main code", otherwise i think its ugly and more like a design failure.
4
3
0
I'm a mechanical engineering student, and I'm building a physical simulation using PyODE. instead of running everything from one file, I wanted to organize stuff in modules so I had: main.py callback.py helper.py I ran into problems when I realized that helper.py needed to reference variables from main, but main was ...
A python module for global parameters - is this good practice?
0.066568
0
0
260
3,402,168
2010-08-04T02:28:00.000
152
0
1
0
python,windows,pythonpath
3,402,193
22
true
0
0
You need to add your new directory to the environment variable PYTHONPATH, separated by a colon from previous contents thereof. In any form of Unix, you can do that in a startup script appropriate to whatever shell you're using (.profile or whatever, depending on your favorite shell) with a command which, again, depen...
5
399
0
Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?
Permanently add a directory to PYTHONPATH?
1.2
0
0
899,731
3,402,168
2010-08-04T02:28:00.000
7
0
1
0
python,windows,pythonpath
7,919,405
22
false
0
0
Just to add on awesomo's answer, you can also add that line into your ~/.bash_profile or ~/.profile
5
399
0
Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?
Permanently add a directory to PYTHONPATH?
1
0
0
899,731
3,402,168
2010-08-04T02:28:00.000
30
0
1
0
python,windows,pythonpath
12,429,896
22
false
0
0
In case anyone is still confused - if you are on a Mac, do the following: Open up Terminal Type open .bash_profile In the text file that pops up, add this line at the end: export PYTHONPATH=$PYTHONPATH:foo/bar Save the file, restart the Terminal, and you're done
5
399
0
Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?
Permanently add a directory to PYTHONPATH?
1
0
0
899,731
3,402,168
2010-08-04T02:28:00.000
55
0
1
0
python,windows,pythonpath
30,728,643
22
false
0
0
This works on Windows On Windows, with Python 2.7 go to the Python setup folder. Open Lib/site-packages. Add an example.pth empty file to this folder. Add the required path to the file, one per each line. Then you'll be able to see all modules within those paths from your scripts.
5
399
0
Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?
Permanently add a directory to PYTHONPATH?
1
0
0
899,731
3,402,168
2010-08-04T02:28:00.000
2
0
1
0
python,windows,pythonpath
45,004,593
22
false
0
0
I added permanently in Windows Vista, Python 3.5 System > Control Panel > Advanced system settings > Advanced (tap) Environment Variables > System variables > (if you don't see PYTHONPATH in Variable column) (click) New > Variable name: PYTHONPATH > Variable value: Please, write the directory in the Variable value. It...
5
399
0
Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH?
Permanently add a directory to PYTHONPATH?
0.01818
0
0
899,731
3,402,271
2010-08-04T02:56:00.000
0
0
1
0
python,curl,urllib2
3,402,359
1
false
0
0
At sizes of 500MB+ one has to worry about data integrity, and HTTP is not designed with data integrity in mind. I'd rather use python bindings for rsync (if they exist) or even bittorrent, which was initially implemented in python. Both rsync and bittorrent address the data integrity issue.
1
1
0
Which library/module is the best to use for downloading large 500mb+ files in terms of speed, memory, cpu? I was also contemplating using pycurl.
best way to download large files with python
0
0
1
2,537
3,402,574
2010-08-04T04:31:00.000
0
0
1
0
python,puzzle,iterator
3,402,637
3
false
0
0
I assume you are trying to find out what is the longest word that can be made from your 10 arbitrary letters. You can keep your 10 arbitrary letters in a dict along with the frequency they occur. e.g., your 4 (using 4 instead of 10 for simplicity) arbitrary letters are: e, w, l, l. This would be in a dict as: {'e':1,...
1
0
0
I have 10 arbitrary letters and need to check the max length match from words file I started to learn RE just some time ago, and can't seem to find suitable pattern first idea that came was using set: [10 chars] but it also repeats included chars and I don't know how to avoid that I stared to learn Python recently b...
Find max length word from arbitrary letters
0
0
0
1,499
3,403,168
2010-08-04T06:40:00.000
0
0
0
0
python,escaping,html-entities
3,405,525
4
false
1
0
You shouldn't use an XML parser to parse data that isn't XML. Find an HTML parser instead, you'll be happier in the long run. The standard library has a few (HTMLParser and htmllib), and BeautifulSoup is a well-loved third-party package.
1
1
0
I'm scraping a html page, then using xml.dom.minidom.parseString() to create a dom object. however, the html page has a '&'. I can use cgi.escape to convert this into &amp; but it also converts all my html <> tags into &lt;&gt; which makes parseString() unhappy. how do i go about this? i would rather not just hack it...
need to selectively escape html entities (&)
0
0
1
576
3,404,055
2010-08-04T09:05:00.000
0
0
0
0
python,django
3,404,200
2
false
1
0
setattr(obj, fieldname, fieldvalue) (see also getattr to retrieve at runtime)
1
0
0
Can anyone help me? I have list of fields called 'allowed_fields' and I have object called 'individual'. allowed_fields is sub set of individual. Now I want to run loop like this for field in allowed_fields: obj.field = individual.field obj have same fields like individual. Do you have solution of my pro...
djangoproject access fields of object dynamically
0
0
0
53
3,404,556
2010-08-04T10:18:00.000
0
0
0
0
python,performance,sqlite
3,536,835
4
false
0
0
You appear to be comparing apples with oranges. A python list is only useful if your data fit into the address-space of the process. Once the data get big, this won't work any more. Moreover, a python list is not indexed - for that you should use a dictionary. Finally, a python list is non-persistent - it is forgotten ...
2
2
0
Lets say I have a database table which consists of three columns: id, field1 and field2. This table may have anywhere between 100 and 100,000 rows in it. I have a python script that should insert 10-1,000 new rows into this table. However, if the new field1 already exists in the table, it should do an UPDATE, not an...
Python performance: search large list vs sqlite
0
1
0
2,505
3,404,556
2010-08-04T10:18:00.000
0
0
0
0
python,performance,sqlite
3,404,589
4
false
0
0
I imagine using a python dictionary would allow for much faster searching than using a python list. (Just set the values to 0, you won't need them, and hopefully a '0' stores compactly.) As for the larger question, I'm curious too. :)
2
2
0
Lets say I have a database table which consists of three columns: id, field1 and field2. This table may have anywhere between 100 and 100,000 rows in it. I have a python script that should insert 10-1,000 new rows into this table. However, if the new field1 already exists in the table, it should do an UPDATE, not an...
Python performance: search large list vs sqlite
0
1
0
2,505
3,404,759
2010-08-04T10:48:00.000
1
0
0
0
python,django
3,404,772
3
false
1
0
You can look in the admin to see how many usernames are there, assuming everyone who likes it creates one. Or you can look at your server logs and count the unique IPs.
2
0
0
I have developed a small django web application. It still runs in the django development web server. It has been decided that if more than 'n' number of users like the application, it will be approved. I want to find out all the users who view my application. How can find the user who views my application? Since I was ...
Finding the user who uses my django web application
0.066568
0
0
206
3,404,759
2010-08-04T10:48:00.000
1
0
0
0
python,django
3,405,077
3
false
1
0
Step 1. Add a model -- connected users. Include an FK to username and a datetime stamp. Step 2. Write a function to log each user's activity. Step 3. Write your own version of login that will call the Django built-in login and also call your function to log each user's activity. Step 4. Write a small application -...
2
0
0
I have developed a small django web application. It still runs in the django development web server. It has been decided that if more than 'n' number of users like the application, it will be approved. I want to find out all the users who view my application. How can find the user who views my application? Since I was ...
Finding the user who uses my django web application
0.066568
0
0
206
3,406,800
2010-08-04T14:58:00.000
1
0
0
0
python,ajax,django
3,407,020
1
false
1
0
None. You'll have to code your own wrapper utility, using one of httplib / urllib / urllib2 libs to connect to the other server. Most likely you will have to extract all the relevant info from the HttpRequest object and use that to manually construct your own request in said util function. Regarding receiving the respo...
1
2
0
I want to make a Django view that does the following: Receive an HttpRequest on api/some/url/or/other Passes this through to another server at some/url/or/other (rewrite the URL, basically) Adding a cookie based on session data in Django Using the same method, data, params, et al, that were in the original request ...
How to make a Django passthrough view?
0.197375
0
0
523
3,408,610
2010-08-04T18:31:00.000
1
1
1
0
.net,visual-studio-2010,ironpython,pysvn
3,408,897
3
false
0
0
I believe you can import pysvn in IronPython, but you have to add python site-packages directory to IRONPYTHONPATH.
1
2
0
Python has a subversion bindings called 'pysvn' that can be used to manipulate subversion repository. Does something similar exists for IronPython? My test platform in Windows 7 64-bit with Visual Studio 2010.
is it possible to access subversion from ironpython?
0.066568
0
0
248
3,408,891
2010-08-04T19:01:00.000
1
0
0
0
python,browser
3,408,987
1
true
0
0
In firefox, if you go to about:config and set browser.link.open_newwindow to "1", that will cause a clicked link that would open in a new window or tab to stay in the current tab. I'm not sure if this applies to calls from 3rd-party apps, but it might be worth a try. Of course, this will now apply to everything you do ...
1
0
0
I am trying to create a python script that opens a single page at a time, however python + mozilla make it so everytime I do this, it opens up a new tab. I want it to keep just a single window open so that it can loop forever without crashing due to too many windows or tabs. It will be going to about 6-7 websites and...
How do I edit the url in python and open a new page without having a new window or tab opened?
1.2
0
1
2,001
3,409,072
2010-08-04T19:25:00.000
2
0
1
0
subprocess,ipython,execution
3,409,938
1
true
0
0
Apparently, such wrapper can be called via ip.IP.getoutput("command").
1
3
0
I'd like to run a new command from IPython configuration and capture its output. Basically, I'd like to access the equivalent of !command via normal functions. I know I can just use subprocess, but since IPython already provides this functionality, I guess there must be a properly made wrapper included somewhere in the...
Running external commands in IPython
1.2
0
0
466
3,409,226
2010-08-04T19:41:00.000
2
1
0
1
python,eclipse,intellisense,pydev
3,409,335
3
false
0
0
I'm using eclipse 3.6 and pydev with python 2.6 and it's the best one I've tested up to now. I didn't try 3.5 so not sure if it's the same as yours but I think it autocompletes well compared to others I tried but I didn't try any of the paid ones.
3
0
0
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
0.132549
0
0
3,548
3,409,226
2010-08-04T19:41:00.000
3
1
0
1
python,eclipse,intellisense,pydev
3,409,439
3
false
0
0
You are probably never going to get something as good as intellisense for python. Due to the dynamic nature of python, it is often impossible to be able to know the type of some variables. And if you don't know their types, you can't do auto-complete on things like class members. Personally, I think the auto-complete ...
3
0
0
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
0.197375
0
0
3,548
3,409,226
2010-08-04T19:41:00.000
0
1
0
1
python,eclipse,intellisense,pydev
9,141,159
3
false
0
0
In Aptana I added the reference to the .egg file to the system PYTHONPATH in Preferences menu. I am not sure if this works for every library out there. Preferences --> PyDev --> Interpreter Python --> Libraries tab on the right.
3
0
0
Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2
How do you get Intellisense for Python in Eclipse/Aptana/Pydev?
0
0
0
3,548
3,409,549
2010-08-04T20:27:00.000
5
0
0
1
python,google-app-engine
3,409,743
1
false
1
0
I would say the blobstore is suitable for this. While datastore entities are limited to 1MB and standard HTTP responses are limited to 10MB, with the blobstore you can upload, store, and serve files up to 2GB. The 30 second limit refers to how long your handler can execute; time spent downloading (or uploading) doesn't...
1
6
0
I'm trying to setup a video streaming app via the Google Appengine Blobstore. Just wanted to know if this was possible, as there isn't too much regarding this in the Appengine Documentation. Basically I want to serve these videos through a flash player. Thanks
Appengine Blobstore - Video Streaming
0.761594
0
0
1,334
3,410,228
2010-08-04T22:05:00.000
2
0
0
0
python,svn,version-control,deployment
3,410,280
1
true
0
0
When it can be broken up in modules, go for a repo / branch with all the 'base' code, and in the actual project, include them as svn:externals (same repository or another one doesn't matter). That way you can independently update / work on modules, pin certain projects to certain revisions of that module or keep them t...
1
0
0
I have a few related applications that I want to deploy to different computers. They each share a large body of common code, and have some things unique to them. For example, I have a server and a client which use a lot of common classes to communicate to each other. I have yet more servers and clients which use some o...
python, svn, deploy applications with shared code
1.2
0
0
270
3,410,296
2010-08-04T22:17:00.000
3
1
1
0
python,shell
3,410,409
3
false
0
0
I don't think it's a bad idea. Lots of people use IPython which is a shell written in Python :) In fact you may want to base your effort around IPython. scipy does this, for example
1
2
0
Why is this such a bad idea? (According to many people)
Writing a Shell in Python?
0.197375
0
0
797
3,410,309
2010-08-04T22:18:00.000
6
1
1
0
python,string
49,795,277
2
false
0
0
In terms of python 2.7 and 3: io.BytesIO is an in-memory file-like object that doesn't do any alteration to newlines, and is similar to open(filename, "wb"). It deal with bytes() strings, which in py2.7 is an alias for str. io.StringIO is an in-memory file-like object that does do alterations to newlines, and is simila...
1
30
0
Besides the obvious (one is a type, the other a class)? What should be preferred? Any notable difference in use cases, perhaps?
What is the difference between StringIO and io.StringIO in Python2.7?
1
0
0
19,774
3,411,006
2010-08-05T00:54:00.000
1
0
1
0
php,python,string
3,599,461
3
true
0
0
Normally, .replace method beats all other methods. (See my benchmarks above.)
1
11
0
Is there any recommended way to do multiple string substitutions other than doing replace chaining on a string (i.e. text.replace(a, b).replace(c, d).replace(e, f)...)? How would you, for example, implement a fast function that behaves like PHP's htmlspecialchars in Python? I compared (1) multiple replace method, (2) t...
Fastest implementation to do multiple string substitutions in Python
1.2
0
0
4,058
3,411,131
2010-08-05T01:30:00.000
1
0
0
0
python,django,path,django-manage.py,devserver
3,411,300
2
true
1
0
manage.py imports settings.py from the current directory and pass settings as parameter to execute_manager. You probably defined project root in settings.py.
1
0
0
I recently moved a django app from c:\Users\user\django-projects\foo\foobar to c:\Python25\Lib\site-packages\foo\foobar (which is on the python path). I started a new app in the django-projects directory, and added foo.foobar to the INSTALLED_APPS setting. When I try to run the dev server (manage.py runserver) for my n...
Where does django dev server (manage.py runserver) get its path from?
1.2
0
0
2,351
3,411,749
2010-08-05T04:29:00.000
50
0
1
0
python,operators
3,411,760
5
true
0
0
It's the right bit shift operator, 'moves' all bits once to the right. 10 in binary is 1010 shifted to the right it turns to 0101 which is 5
2
33
0
What does the >> operator do? For example, what does the following operation 10 >> 1 = 5 do?
>> operator in Python
1.2
0
0
48,345
3,411,749
2010-08-05T04:29:00.000
3
0
1
0
python,operators
3,411,765
5
false
0
0
Its the right shift operator. 10 in binary is 1010 now >> 1 says to right shift by 1, effectively loosing the least significant bit to give 101, which is 5 represented in binary. In effect it divides the number by 2.
2
33
0
What does the >> operator do? For example, what does the following operation 10 >> 1 = 5 do?
>> operator in Python
0.119427
0
0
48,345
3,413,879
2010-08-05T10:39:00.000
4
0
0
0
python,r,vector,rpy2
20,171,517
7
false
0
0
As pointed out by Brani, vector() is a solution, e.g. newVector <- vector(mode = "numeric", length = 50) will return a vector named "newVector" with 50 "0"'s as initial values. It is also fairly common to just add the new scalar to an existing vector to arrive at an expanded vector, e.g. aVector <- c(aVector, newScalar...
1
104
1
I want to use R in Python, as provided by the module Rpy2. I notice that R has very convenient [] operations by which you can extract the specific columns or lines. How could I achieve such a function by Python scripts? My idea is to create an R vector and add those wanted elements into this vector so that the final ve...
How to create an empty R vector to add new items
0.113791
0
0
291,651
3,415,298
2010-08-05T13:49:00.000
13
0
1
0
python,bit-manipulation
3,415,333
6
true
0
0
This is done by first masking the bits you want to erase (forcing them to zero while preserving the other bits) before applying the bitwise OR. Use a bitwise AND with the pattern (in this case) 11100111. If you already have a "positive" version of the pattern (here this would be 00011000), which is easier to generate, ...
1
8
0
Given a series of bits, what's the best way to overwrite a particular range of them. For example, given: 0100 1010 Say I want to overwrite the middle 2 bits with 10 to make the result: 0101 0010 What would be the best way of doing this? At first, I thought I would just shift the overwriting bits I want to the correct p...
Best way to overwrite some bits in a particular range
1.2
0
0
5,765
3,416,342
2010-08-05T15:29:00.000
2
1
0
0
c++,python
3,416,435
8
false
0
0
If you are new to programming, I would say start with the C++ class. If you get the hang of it and enjoy programming, you can always learn Python later. There are a wealth of good books and Internet resources on pretty much any programming language out there that you should be able to teach yourself any language in y...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
0.049958
0
0
4,081
3,416,342
2010-08-05T15:29:00.000
0
1
0
0
c++,python
3,648,941
8
false
0
0
You've got to find out what people in your field are programming with so you can leverage existing libraries/APIs/projects. It won't do you any good re-inventing the wheel in C++ or Python if there's some wicked-cool FORTRAN library out there that is standard in your field. (And, if that is the case, God help you, I'...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
0
0
0
4,081
3,416,342
2010-08-05T15:29:00.000
0
1
0
0
c++,python
3,648,912
8
false
0
0
I come from a computational maths background, and have written sizeable (commercial and accademic) programs in both C++ and python. They are very different languages and I would probably learn one first (or only one). Which one would depend on what you want to be able to do with the language. If you want to build somet...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
0
0
0
4,081
3,416,342
2010-08-05T15:29:00.000
7
1
0
0
c++,python
3,416,441
8
false
0
0
You'll get holes in the head. Python's data structures and memory management are radically different from C++. Whichever language you "get" first, you'll love. The other you'll hate. Indeed, you'll be confused at the weird things one language lacks that the other has. One language will be reasonable, logical, unsu...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
1
0
0
4,081
3,416,342
2010-08-05T15:29:00.000
1
1
0
0
c++,python
3,416,466
8
false
0
0
I think that given the circumstances (fulltime employee, etc) studying one language will be hard enough. Pick one, then study another. You'll learn basics from either language. As for "which language to pick"... I specialize in C++, and know a bit of python. C++ is much more difficult, more flexible, and more suitable ...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
0.024995
0
0
4,081
3,416,342
2010-08-05T15:29:00.000
0
1
0
0
c++,python
3,648,838
8
false
0
0
I think you pretty much answered this question yourself: I was told that Python is great for that but our course does not cover basics for beginners. In other words, the Python course is not an introductory course -- it assumes you already know how the basics of programming. That's probably why the professor suggest...
6
0
0
I am totally new to programming as though I have my PhD as a molecular biologist for the last 10 years. Can someone please tell me: Would it be too hard to handle if I enrolled simultaneously in C++ and python? I am a full time employee too. Both courses start and finish on the same dates and is for 3 months. For a var...
C++ and python simultaneously. Is it doable
0
0
0
4,081
3,417,756
2010-08-05T18:09:00.000
0
0
0
0
python,tabs,python-webbrowser
3,418,619
1
true
0
0
On WinXP, at least, it appears that this is not possible (from my tests with IE). From what I can see, webbrowser is a fairly simple convenience module that creates (probably ) a subprocess-style call to the browser executable. If you want that sort of granularity you'll have to see if your browser accepts command lin...
1
3
0
I would like to open a new tab in my web browser using python's webbrowser. However, now my browser is brought to the top and I am directly moved to the opened tab. I haven't found any information about this in documentation, but maybe there is some hidden api. Can I open this tab in the possible most unobtrusive way, ...
python: open unfocused tab with webbrowser
1.2
0
1
392
3,418,834
2010-08-05T20:18:00.000
5
0
1
0
python,exception-handling
3,418,859
2
true
0
0
print_exc() doesn't return anything, which in Python is actually returning None. Looks like IDLE is showing you the None it returned.
2
1
0
I am using the following line of code in IDLE to print out my traceback in an eception: traceback.print_exc() For some reason I get the red text error message, but then it is followed by a blue text of "None". Not sure what that None is about, any ideas?
traceback.print_exc() python question
1.2
0
0
4,068
3,418,834
2010-08-05T20:18:00.000
7
0
1
0
python,exception-handling
3,419,961
2
false
0
0
print_exc() prints formatted exception to stderr. If you need string value, call format_exc()
2
1
0
I am using the following line of code in IDLE to print out my traceback in an eception: traceback.print_exc() For some reason I get the red text error message, but then it is followed by a blue text of "None". Not sure what that None is about, any ideas?
traceback.print_exc() python question
1
0
0
4,068
3,419,282
2010-08-05T21:24:00.000
3
0
1
0
python,overloading
3,419,420
2
true
0
1
TypeError is just another Exception. You can take *args **kwargs, check those, and raise a TypeError yourself, specify the text displayed - e.g. listing the expected call. That being said, PyQt is a bunch of .pyd == native python extension, written in C or C++ (using Boost::Python). At least the latter supports "real" ...
2
1
0
If I call QApplication's init without arguments i get TypeError: arguments did not match any overloaded call: QApplication(list-of-str): not enough arguments QApplication(list-of-str, bool): not enough arguments QApplication(list-of-str, QApplication.Type): not enough arguments QApplication(Display, int visual...
Python method overload based on argument count?
1.2
0
0
1,044
3,419,282
2010-08-05T21:24:00.000
0
0
1
0
python,overloading
3,419,307
2
false
0
1
It's quite possible that its init is simply using __init__(self, *args, **kwargs) and then doing its own signature testing against the args list and kwargs dict.
2
1
0
If I call QApplication's init without arguments i get TypeError: arguments did not match any overloaded call: QApplication(list-of-str): not enough arguments QApplication(list-of-str, bool): not enough arguments QApplication(list-of-str, QApplication.Type): not enough arguments QApplication(Display, int visual...
Python method overload based on argument count?
0
0
0
1,044
3,419,624
2010-08-05T22:13:00.000
4
0
1
0
python,sql
3,419,835
5
true
0
0
I don't know exactly what you are doing. But a database will just change how the data is stored. and in fact it might take longer since most reasonable databases may have constraints put on columns and additional processing for the checks. In many cases having the whole file local, going through and doing calculatio...
5
4
0
i am reading a csv file into a list of a list in python. it is around 100mb right now. in a couple of years that file will go to 2-5gigs. i am doing lots of log calculations on the data. the 100mb file is taking the script around 1 minute to do. after the script does a lot of fiddling with the data, it creates URL's th...
python or database?
1.2
1
0
1,357
3,419,624
2010-08-05T22:13:00.000
2
0
1
0
python,sql
3,419,871
5
false
0
0
I always reach for a database for larger datasets. A database gives me some stuff for "free"; that is, I don't have to code it. searching sorting indexing language-independent connections Something like SQLite might be the answer for you. Also, you should investigate the "nosql" databases; it sounds like your prob...
5
4
0
i am reading a csv file into a list of a list in python. it is around 100mb right now. in a couple of years that file will go to 2-5gigs. i am doing lots of log calculations on the data. the 100mb file is taking the script around 1 minute to do. after the script does a lot of fiddling with the data, it creates URL's th...
python or database?
0.07983
1
0
1,357
3,419,624
2010-08-05T22:13:00.000
4
0
1
0
python,sql
3,419,726
5
false
0
0
If you need to go through all lines each time you perform the "fiddling" it wouldn't really make much difference, assuming the actual "fiddling" is whats eating your cycles. Perhaps you could store the results of your calculations somehow, then a database would probably be nice. Also, databases have methods for ensurin...
5
4
0
i am reading a csv file into a list of a list in python. it is around 100mb right now. in a couple of years that file will go to 2-5gigs. i am doing lots of log calculations on the data. the 100mb file is taking the script around 1 minute to do. after the script does a lot of fiddling with the data, it creates URL's th...
python or database?
0.158649
1
0
1,357
3,419,624
2010-08-05T22:13:00.000
4
0
1
0
python,sql
3,419,718
5
false
0
0
I'd only put it into a relational database if: The data is actually relational and expressing it that way helps shrink the size of the data set by normalizing it. You can take advantage of triggers and stored procedures to offload some of the calculations that your Python code is performing now. You can take advantage...
5
4
0
i am reading a csv file into a list of a list in python. it is around 100mb right now. in a couple of years that file will go to 2-5gigs. i am doing lots of log calculations on the data. the 100mb file is taking the script around 1 minute to do. after the script does a lot of fiddling with the data, it creates URL's th...
python or database?
0.158649
1
0
1,357
3,419,624
2010-08-05T22:13:00.000
1
0
1
0
python,sql
3,419,687
5
false
0
0
At 2 gigs, you may start running up against speed issues. I work with model simulations for which it calls hundreds of csv files and it takes about an hour to go through 3 iterations, or about 20 minutes per loop. This is a matter of personal preference, but I would go with something like PostGreSql because it integr...
5
4
0
i am reading a csv file into a list of a list in python. it is around 100mb right now. in a couple of years that file will go to 2-5gigs. i am doing lots of log calculations on the data. the 100mb file is taking the script around 1 minute to do. after the script does a lot of fiddling with the data, it creates URL's th...
python or database?
0.039979
1
0
1,357
3,420,594
2010-08-06T02:18:00.000
6
0
0
0
.net,python,sql-server,django,asp.net-mvc-2
22,076,548
4
false
1
0
I would also suggest we must compare runtimes and not limit to language features before making such moves. Python runs via interpreter CPython where C# runs on CLR in their default implementations. Multitasking is very important in any large scale project; .NET can easily handle this via threads... and also it can tak...
1
58
0
My organization currently delivers a web application primarily based on a SQL Server 2005/2008 back end, a framework of Java models/controllers, and ColdFusion-based views. We have decided to transition to a newer framework and after internal explorations and mini projects have narrowed the choice down to between Pyth...
Python vs C#/.NET -- what are the key differences to consider for using one to develop a large web application?
1
0
0
86,003
3,421,200
2010-08-06T05:27:00.000
12
0
0
0
python,web-services,twisted,network-protocols,amqp
3,426,017
1
true
1
0
As always, "it depends". First, let's clear up the terminology. Twisted's Perspective Broker basically is a system you can use when you have control over both ends of a distributed action (both client and server ends). It provides a way to copy objects from one end to the other and to call methods on remote objects. Co...
1
4
0
I'm currently using twisted's perspective broker on python and I have considered in the past switching to something like RabbitMQ but I'm not sure it could just replace pb - I feel like I might be comparing apples to oranges here. I've been reading a lot about REST lately and the inevitable debate with SOAP, which led ...
Simple protocols (like twisted.pb) vs messaging (AMQP/JMS) vs web services (REST/SOAP)
1.2
0
0
2,230
3,422,457
2010-08-06T09:20:00.000
2
0
0
0
python,base64,byte
3,422,530
3
false
0
0
Each base64 encoded string should be decoded separately - you can't concatenate encoded strings (and get a correct decoding). The result of the decode is a string, of byte-buffer - in Python, they're equivalent. Regarding the network/host order - sequences of bytes, have no such 'order' (or endianity) - it only matters...
1
0
0
I am now using python base64 module to decode a base64 coded XML file, what I did was to find each of the data (there are thousands of them as for exmaple in "ABC....", the "ABC..." was the base64 encoded data) and add it to a string, lets say s, then I use base64.b64decode(s) to get the result, I am not sure of the re...
Python base64 data decode and byte order convert
0.132549
0
1
7,855
3,423,510
2010-08-06T11:58:00.000
0
1
0
0
python,comparison,md5
3,423,577
3
false
0
0
You can log in using ssh and make a md5 hash for the file remotely and a md5 hash for the current local file. If the md5s are matching the files are identicaly, else they are different.
2
2
0
I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and co...
Comparing local file with remote file
0
0
0
4,055
3,423,510
2010-08-06T11:58:00.000
0
1
0
0
python,comparison,md5
3,423,559
3
false
0
0
I would like to know how you intend to compare them locally, if it were the case. You can apply the same logic to compare them remotely.
2
2
0
I have the following problem: I have a local .zip file and a .zip file located on a server. I need to check if the .zip file on the server is different from the local one; if they are not I need to pull the new one from the server. My question is how do I compare them without downloading the file from the server and co...
Comparing local file with remote file
0
0
0
4,055
3,423,845
2010-08-06T12:45:00.000
1
0
0
0
python,performance,twisted
3,433,333
3
false
0
0
If I understand Twisted Reactors correctly, they don't parallelize everything. Whatever operations have been queued is scheduled and is done one by one. One way out for you is to have a custom addCallback which checks for how many callbacks have been registered already and drop if necessary.
2
4
0
Is it somehow possible to "detect" that the reactor is overloaded and start dropping connections, or refuse new connections? How can we avoid the reactor being completely overloaded and not being able to catch up?
Twisted: degrade gracefully performance in case reactor is overloaded?
0.066568
0
0
487
3,423,845
2010-08-06T12:45:00.000
1
0
0
0
python,performance,twisted
3,445,076
3
false
0
0
I would approach this per protocol. Throttle when the actual service requires it, not when you think it will. Rather than worrying about how many callbacks are waiting for a reactor tick, I'd worry about how long the HTTP requests (for example) are taking to complete. The number of operations waiting for the reactor...
2
4
0
Is it somehow possible to "detect" that the reactor is overloaded and start dropping connections, or refuse new connections? How can we avoid the reactor being completely overloaded and not being able to catch up?
Twisted: degrade gracefully performance in case reactor is overloaded?
0.066568
0
0
487
3,424,899
2010-08-06T14:48:00.000
0
0
1
0
python,date
47,685,571
23
false
0
0
You can use below given function to get date before/after X month. from datetime import date def next_month(given_date, month): yyyy = int(((given_date.year * 12 + given_date.month) + month)/12) mm = int(((given_date.year * 12 + given_date.month) + month)%12) if mm == 0: yyyy -= 1 mm = 12...
4
136
0
If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's ...
Return datetime object of previous month
0
0
0
176,482
3,424,899
2010-08-06T14:48:00.000
1
0
1
0
python,date
61,557,952
23
false
0
0
One liner ? previous_month_date = (current_date - datetime.timedelta(days=current_date.day+1)).replace(day=current_date.day)
4
136
0
If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's ...
Return datetime object of previous month
0.008695
0
0
176,482
3,424,899
2010-08-06T14:48:00.000
20
0
1
0
python,date
3,425,016
23
false
0
0
If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? What do you want the result to be when you subtract a month from, say, a date that is March 30? That is the problem with adding or subtracting months: months have different lengths! In some application an exception...
4
136
0
If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's ...
Return datetime object of previous month
1
0
0
176,482
3,424,899
2010-08-06T14:48:00.000
43
0
1
0
python,date
56,550,913
23
false
0
0
A vectorized, pandas solution is very simple: df['date'] - pd.DateOffset(months=1)
4
136
0
If only timedelta had a month argument in it's constructor. So what's the simplest way to do this? EDIT: I wasn't thinking too hard about this as was pointed out below. Really what I wanted was any day in the last month because eventually I'm going to grab the year and month only. So given a datetime object, what's ...
Return datetime object of previous month
1
0
0
176,482
3,425,643
2010-08-06T16:12:00.000
1
0
1
1
python,applescript
3,426,504
1
true
0
0
Seeing as how py-appscript is a layer between python and the application you are scripting via Applescript, I would suggest porting the statement to pure Applescript and see if it works there. There are a lot of things that can go wrong with Applescript (and your statement alone) to begin with and it's not obvious what...
1
0
0
i have a py2app application, which runs an appscript using py-appscript. the Applescript code is this one line: app('Finder').update(<file alias of a certain file>) What this normally does is update a file's preview in Finder. It works most of the time, except for Leopard. In Leopard, everytime that script is executed,...
py-appscript is starting a new Finder instance
1.2
0
0
266
3,427,287
2010-08-06T19:56:00.000
2
0
0
0
python,django,passenger,wsgi
3,428,960
1
true
1
0
My advice would be to test locally using Django's builtin server. It does precisely auto-reload, so that any change to your code will be available. I'm not familiar with Dreamhost, but if modwsgi is on embedded mode this is not possible. In Daemon mode, you could write some code to detect file changes and restart the p...
1
1
0
I am using Django with Passenger on Dreamhost. Every time I make a change to models, settings or views I need to pkill python from a terminal session. Does anyone know of a way to automate this? Is this something that Passenger can do?
Is there a way to automate restarting the python process after every change I make to Django models?
1.2
0
0
205
3,427,505
2010-08-06T20:24:00.000
1
0
0
0
python,django,postgresql,ipython
3,428,147
1
false
1
0
You may always run a cron job, that will call pg_cancel_backend() within the database, for the backends that are idle for longer than e.g. 1 day (of course that depends on the nagios settings).
1
2
0
It's not the fault of the django (iPython) shell, actually. The problem is developers who open the django shell ./manage.py shell run through some queries (it often only generates selects), and then either leave the shell running or somehow kill their (ssh) session (actually, I'm not sure if the latter case leaves the ...
django shell triggering Postgres idle transaction problems
0.197375
0
0
437
3,427,795
2010-08-06T21:05:00.000
3
0
1
0
.net,python,language-agnostic,naming-conventions
3,427,822
12
false
0
0
I'd recommend purchasing a copy of "Clean Code" by Robert C. Martin. It is full of great suggstions ranging from naming conventions to how to write easy-to-understand functions and much more. Definitely worth a read. I know it influenced my coding style since reading it.
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.049958
0
0
509
3,427,795
2010-08-06T21:05:00.000
2
0
1
0
.net,python,language-agnostic,naming-conventions
3,427,834
12
false
0
0
Have you read Code Complete? He does a full treatise on this in the book. Definitely the best naming strategy I've seen in print... And it's easy to find like 1000 programmers at the drop of a hat who name this one of the top 5 resources for programmers and program design. Just my $.05
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.033321
0
0
509
3,427,795
2010-08-06T21:05:00.000
3
0
1
0
.net,python,language-agnostic,naming-conventions
3,427,856
12
false
0
0
There are many different views on the specifics of naming conventions, but the overall gist could be summed up as: Each variable name should be relevant to whatever data is stored in the variable. Your naming scheme should be consistent. So a major no-no would be single letter variables (some people use i and j ...
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.049958
0
0
509
3,427,795
2010-08-06T21:05:00.000
1
0
1
0
.net,python,language-agnostic,naming-conventions
3,428,775
12
false
0
0
It's not clear if your question relates to Python naming conventions. If so, for starters I would try to follow just these simple rules: ClassName - upper case for class names variable_name - lower case and underscore for variables (I try to keep them at two words maximum)
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.016665
0
0
509
3,427,795
2010-08-06T21:05:00.000
5
0
1
0
.net,python,language-agnostic,naming-conventions
3,428,433
12
false
0
0
A bad convention followed fully is better than a combination of different good "conventions" (which aren't conventions at all any more, if they aren't kept to). However, a convention that is making something less clear than if it had been ignored, should be ignored. Those are the only two I would state as any sort of ...
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.083141
0
0
509
3,427,795
2010-08-06T21:05:00.000
4
0
1
0
.net,python,language-agnostic,naming-conventions
3,428,164
12
true
0
0
All the answers here are quite valid. Most important: be consistent. That said, here are my rules (C#): camelCase identifiers -- I personally find this much easier to read than underscores Public properties start with a capital letter Something I should never touch starts with an underscore -- example, the backing fi...
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
1.2
0
0
509
3,427,795
2010-08-06T21:05:00.000
1
0
1
0
.net,python,language-agnostic,naming-conventions
3,428,577
12
false
0
0
Can I make a shameless plug for the "Names" chapter in my book, "A Sane Approach to Database Design" ? I'm specifically talking about names for things in databases, but most of the same considerations apply to variables in programs.
7
4
0
as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?
are there tutorials on how to name variables?
0.016665
0
0
509
3,427,946
2010-08-06T21:31:00.000
2
0
0
1
java,python,google-app-engine,web-applications,stripes
3,428,411
9
false
1
0
As many things in life, this depends on what your goals are. If you intend to learn a web framework that is used in corporate environments, then choose a Java solution. If not, don't. Python is certainly more elegant and generally more fun in pretty much every way. As to which framework to use, django has the most mind...
5
2
0
I plan to start a mid sized web project, what language + framework would you recommend? I know Java and Python. I am looking for something simple. Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standar...
What language (Java or Python) + framework for mid sized web project?
0.044415
0
0
492
3,427,946
2010-08-06T21:31:00.000
0
0
0
1
java,python,google-app-engine,web-applications,stripes
3,428,479
9
false
1
0
It depends on your personality. There's no right answer to this question any more than there's a right answer to "what kind of car should I drive?" If you're artistic and believe code should be beautiful, use Rails. If you're a real hacker type, I think you'll find a full-stack framework such as Rails or Django to be u...
5
2
0
I plan to start a mid sized web project, what language + framework would you recommend? I know Java and Python. I am looking for something simple. Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standar...
What language (Java or Python) + framework for mid sized web project?
0
0
0
492
3,427,946
2010-08-06T21:31:00.000
0
0
0
1
java,python,google-app-engine,web-applications,stripes
3,428,497
9
false
1
0
Google App Engine + GWT and you have a pretty powerful combination for developing web applications. The datastore is quite fast, and it has so far done the job quite nicely for me. In my project I had to do a lot of redesigning of my database model, because it was made for a traditional relational database, and some t...
5
2
0
I plan to start a mid sized web project, what language + framework would you recommend? I know Java and Python. I am looking for something simple. Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standar...
What language (Java or Python) + framework for mid sized web project?
0
0
0
492
3,427,946
2010-08-06T21:31:00.000
0
0
0
1
java,python,google-app-engine,web-applications,stripes
3,428,141
9
false
1
0
I don't think the datastore is a problem. Many people will reject it out of hand because they want a standard relational database; if you are willing to consider a datastore in general then I doubt you will have any problems with the GAE datastore. Personally, I quite like it. The thing that might trip you up is the ...
5
2
0
I plan to start a mid sized web project, what language + framework would you recommend? I know Java and Python. I am looking for something simple. Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standar...
What language (Java or Python) + framework for mid sized web project?
0
0
0
492
3,427,946
2010-08-06T21:31:00.000
0
0
0
1
java,python,google-app-engine,web-applications,stripes
3,430,891
9
false
1
0
I've built several apps on GAE (with Python) over the last year. It's hard to beat the ease with which you can get an app up and running quickly. Don't discount the value in that alone. While you may not understand the datastore yet, it is extremely well documented and there are great resources - including this one - ...
5
2
0
I plan to start a mid sized web project, what language + framework would you recommend? I know Java and Python. I am looking for something simple. Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standar...
What language (Java or Python) + framework for mid sized web project?
0
0
0
492
3,428,245
2010-08-06T22:29:00.000
18
1
1
0
python
3,428,288
2
true
0
0
I would recommend studying the Standard Python Library (all the parts of it that are coded in Python, that is) -- it's not uniformly excellent in elegance, but it sets a pretty high standard. Plus, the study has the extra benefit of making you very familiar with the library itself (an absolutely crucial part of master...
1
13
0
I am trying to teach myself Python, and I have realized that the only way I really learn stuff is by reading the actual programs. Tutorials/manuals just cause me to feel deeply confused. It's just my learning style, and I'm like that with everything I've studied (including natural languages -- I've managed to teach my...
Elegant Python?
1.2
0
0
2,872
3,429,159
2010-08-07T04:47:00.000
3
0
1
0
python,multithreading,ironpython,jython,gil
3,429,166
2
false
0
0
My guess, because the C libraries that CPython is built upon aren't thread-safe. Whereas Jython and IronPython are built against the Java and .Net respectively.
1
6
0
Why is it that you can run Jython and IronPython without the need for a GIL but Python (CPython) requires a GIL?
Python requires a GIL. But Jython & IronPython don't. Why?
0.291313
0
0
2,607
3,429,887
2010-08-07T09:23:00.000
3
1
0
0
python,android,eclipse,workspace,eclipse-pdt
3,430,003
2
true
1
0
The plug-ins are stored in the Eclipse installation, not in the workspace folder. So one solution would be to different Eclipse installations for every task, in this case only the required plug-ins would load (and the others not available), on the other hand, you have to maintain at least three parallel Eclipse install...
1
4
0
I use Eclipse for programming in PHP (PDT), Python and sometimes Android. Each of this programming languages requires to run many things after Eclipse start. Of course I do not use all of them at one moment, I have different workspace for each of those. Is there any way, or recommendation, how to make Eclipse to run on...
How to organize Eclipse - Workspace VS Programming languages
1.2
0
0
741
3,430,016
2010-08-07T10:08:00.000
1
1
1
0
python,algorithm,data-structures,md5,base64
3,452,248
4
true
0
0
David gave an answer that works on all base64 strings. Just use base64.decodestring in base64 module. That is, import base64 binary = base64.decodestring(base64_string) is a more memory efficient representation of the original base64 string. If you are truncating trailing '==' in your base64 md5, use it like base64.de...
3
4
0
Suppose you have a MD5 hash encoded in base64. Then each character needs only 6 bits to store each character in the resultant 22-byte string (excluding the ending '=='). Thus, each base64 md5 hash can shrink down to 6*22 = 132 bits, which requires 25% less memory space compared to the original 8*22=176 bits string. I...
Most memory-efficient way of holding base64 data in Python?
1.2
0
0
1,820
3,430,016
2010-08-07T10:08:00.000
4
1
1
0
python,algorithm,data-structures,md5,base64
3,430,256
4
false
0
0
"store base64 data" Don't. Do. Not. Store. Base64. Data. Base64 is built by encoding something to make it bigger. Store the original something. Never store the base64 encoding of something.
3
4
0
Suppose you have a MD5 hash encoded in base64. Then each character needs only 6 bits to store each character in the resultant 22-byte string (excluding the ending '=='). Thus, each base64 md5 hash can shrink down to 6*22 = 132 bits, which requires 25% less memory space compared to the original 8*22=176 bits string. I...
Most memory-efficient way of holding base64 data in Python?
0.197375
0
0
1,820
3,430,016
2010-08-07T10:08:00.000
8
1
1
0
python,algorithm,data-structures,md5,base64
3,430,100
4
false
0
0
The most efficient way to store base64 encoded data is to decode it and store it as binary. base64 is a transport encoding - there's no sense in storing data in it, especially in memory, unless you have a compelling reason otherwise. Also, nitpick: The output of a hash function is not a hex string - that's just a commo...
3
4
0
Suppose you have a MD5 hash encoded in base64. Then each character needs only 6 bits to store each character in the resultant 22-byte string (excluding the ending '=='). Thus, each base64 md5 hash can shrink down to 6*22 = 132 bits, which requires 25% less memory space compared to the original 8*22=176 bits string. I...
Most memory-efficient way of holding base64 data in Python?
1
0
0
1,820
3,431,154
2010-08-07T16:25:00.000
0
0
0
0
python,wxpython
3,431,426
2
false
0
1
You could put each picture in a panel, and use SetBackgroundColour()to set the background color of the panel.
1
1
0
I have a Panel with a bunch of pictures placed on it in a GridSizer layout. How can I draw a highlighted color around the edge of an image or its border to show that it has been selected upon a mouse click event?
wxPython: Highlight item in GidSizer upon mouse click
0
0
0
233
3,431,844
2010-08-07T19:55:00.000
1
0
1
1
python,tar
3,431,918
1
true
0
0
You can't scan the contents of a tar without scanning the entire file; it has no central index. You need something like a ZIP.
1
0
0
I use python tarfile module. I have a system backup in tar.gz file. I need to get first level dirs and files list without getting ALL the list of files in the archive because it's TOO LONG. For example: I need to get ['bin/', 'etc/', ... 'var/'] and that's all. How can I do it? May be not even with a tar-file? Then how...
Get big TAR(gz)-file contents by dir levels
1.2
0
0
247
3,433,131
2010-08-08T04:58:00.000
10
0
0
0
python,django,django-models,model
3,433,146
2
true
1
0
You can use ModelName.add_to_class (or .contribute_to_class), but if you have already run syncdb, then there is no way to automatically have it add the columns you need. For maintainable code, you will probably want to extend by sub-classing the desired model in your own app, and use something like south to handle the ...
1
10
0
I want to add a column to a database table but I don't want to modify the 3rd party module in case I need/decide to upgrade the module in the future. Is there a way I can add this field within my code so that with new builds I don't have to add the field manually?
Django - how to extend 3rd party models without modifying
1.2
0
0
3,026
3,433,559
2010-08-08T08:09:00.000
2
0
1
0
python,time
67,426,999
4
false
0
0
If the non-block feature is not needed, just use time.sleep(5) which will work anywhere and save your life.
2
57
0
I want to know how to call a function after a certain time. I have tried time.sleep() but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time
Python Time Delays
0.099668
0
0
55,176
3,433,559
2010-08-08T08:09:00.000
5
0
1
0
python,time
3,434,738
4
false
0
0
If you want a function to be called after a while and not to stop your script you are inherently dealing with threaded code. If you want to set a function to be called and not to worry about it, you have to either explicitly use multi-threading - like em Mark Byers's answr, or use a coding framework that has a main loo...
2
57
0
I want to know how to call a function after a certain time. I have tried time.sleep() but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time
Python Time Delays
0.244919
0
0
55,176
3,438,531
2010-08-09T08:50:00.000
5
0
1
1
python,user-interface,ipython,python-idle
11,456,303
14
false
0
0
Try Spyder, I have spent all day trying to find an IDE which has the functionality of ipython and Spyder just kicks it out of the park.. Autocomplete is top notch right from install, no config files and all that crap, and it has an Ipython terminal in the corner for you to instantly run your code. big thumbs up
1
51
0
Is there a GUI for IPython that allows me to open/run/edit Python files? My way of working in IDLE is to have two windows open: the shell and a .py file. I edit the .py file, run it, and interact with the results in the shell. Is it possible to use IPython like this? Or is there an alternative way of working?
IPython workflow (edit, run)
0.071307
0
0
33,816
3,439,020
2010-08-09T10:14:00.000
1
0
0
1
python,queue,task
3,439,041
3
false
0
0
This is a bit of a vague question. One thing you should remember is that it is very difficult to leak memory in Python, because of the automatic garbage collection. croning a Python script to handle the queue isn't very nice, although it would work fine. I would use method 1; if you need more power you could make a sma...
1
0
0
Task is: I have task queue stored in db. It grows. I need to solve tasks by python script when I have resources for it. I see two ways: python script working all the time. But i don't like it (reason posible memory leak). python script called by cron and do a little part of task. But i need to solve the problem of one...
Tasks queue process in python
0.066568
0
0
883