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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,502,345 | 2010-03-23T17:56:00.000 | 2 | 1 | 0 | 0 | python,hudson | 2,502,582 | 3 | false | 0 | 0 | Well, after some more debugging, I realized that the pylint output file referenced the source code files relative to where pylint was being run, which wasn't the same path that Hudson needed. Basically, Violations needed the paths relative to the Hudson workspace. | 1 | 3 | 0 | I'm using Hudson CI with a Python project. I've installed the Violations plugin and configured it to run the code against pylint. This works, but I only see a list of violations without linking to the source code. Is it possible to setup Violations and pylint to load and highlight the violating source files (something similar to the Cobertura Coverage Reports)?
Better yet, can Violations integrate with pep8.py? | Is it possible to see the source code of the violating files in Hudson with Violations and Pylint? | 0.132549 | 0 | 0 | 600 |
2,502,385 | 2010-03-23T18:02:00.000 | 0 | 0 | 0 | 1 | python,image,vbscript,batch-file,console-application | 2,502,963 | 4 | false | 0 | 1 | Try TK, it is included with python. Also, PyGtk is lighter than wxPython, but I ended up bitting the bullet and using wxPython for the same purpose recently, it is heavy, but it didn't have any affect on the script performance. | 1 | 2 | 0 | Any ideas how I can display an image file (bmp or png) centered on the screen as an application splash screen when running a Windows console script based on a batch file, vbscript/wscript or Python console script?
I'm not interested in a wxPython solution - that's too much overhead just to implement a cosmetic feature like a splash screen.
Thank you,
Malcolm | Display an image as a splash screen when running Windows batch file, vbscript/wscript or Python console script | 0 | 0 | 0 | 5,541 |
2,503,444 | 2010-03-23T20:40:00.000 | 4 | 1 | 1 | 0 | python | 2,503,474 | 10 | false | 0 | 0 | If you write good unit tests for all of your code, you should find the errors very quickly when testing code. | 3 | 11 | 0 | I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.
Over time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.
So I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers?
Please share... | What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute x)? | 0.07983 | 0 | 0 | 2,459 |
2,503,444 | 2010-03-23T20:40:00.000 | 8 | 1 | 1 | 0 | python | 2,503,704 | 10 | true | 0 | 0 | forgetting to check a type
This doesn't make much sense. You so rarely need to "check" a type. You simply run unit tests and if you've provided the wrong type object, things fail. You never need to "check" much, in my experience.
trying to call an attribute and
getting the NoneType (or any other)
has no attribute x error.
Unexpected None is a plain-old bug. 80% of the time, I omitted the return. Unit tests always reveal these.
Of those that remain, 80% of the time, they're plain old bugs due to an "early exit" which returns None because someone wrote an incomplete return statement. These if foo: return structures are easy to detect with unit tests. In some cases, they should have been if foo: return somethingMeaningful, and in still other cases, they should have been if foo: raise Exception("Foo").
The rest are dumb mistakes misreading the API's. Generally, mutator functions don't return anything. Sometimes I forget. Unit tests find these quickly, since basically, nothing works right.
That covers the "unexpected None" cases pretty solidly. Easy to unit test for. Most of the mistakes involve fairly trivial-to-write tests for some pretty obvious species of mistakes: wrong return; failure to raise an exception.
Other "has no attribute X" errors are really wild mistakes where a totally wrong type was used. That's either really wrong assignment statements or really wrong function (or method) calls. They always fail elaborately during unit testing, requiring very little effort to fix.
A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.
Um... Harmless? If it's a bug, I pray that it brings down my entire app as quickly as possible so I can find it. A bug that doesn't crash my app is the most horrible situation imaginable. "Harmless" isn't a word I'd use for a bug that fails to crash my app. | 3 | 11 | 0 | I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.
Over time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.
So I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers?
Please share... | What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute x)? | 1.2 | 0 | 0 | 2,459 |
2,503,444 | 2010-03-23T20:40:00.000 | 0 | 1 | 1 | 0 | python | 2,503,535 | 10 | false | 0 | 0 | I haven’t done a lot of Python programming, but I’ve done no programming at all in staticly typed languages, so I don’t tend to think about things in terms of variable types. That might explain why I haven’t come across this problem much. (Although the small amount of Python programming I’ve done might explain that too.)
I do enjoy Python 3’s revised handling of strings (i.e. all strings are unicode, everything else is just a stream of bytes), because in Python 2 you might not notice TypeErrors until dealing with unusual real world string values. | 3 | 11 | 0 | I'm not sure if I like Python's dynamic-ness. It often results in me forgetting to check a type, trying to call an attribute and getting the NoneType (or any other) has no attribute x error. A lot of them are pretty harmless but if not handled correctly they can bring down your entire app/process/etc.
Over time I got better predicting where these could pop up and adding explicit type checking, but because I'm only human I miss one occasionally and then some end-user finds it.
So I'm interested in your strategy to avoid these. Do you use type-checking decorators? Maybe special object wrappers?
Please share... | What is your strategy to avoid dynamic typing errors in Python (NoneType has no attribute x)? | 0 | 0 | 0 | 2,459 |
2,503,562 | 2010-03-23T20:56:00.000 | 1 | 0 | 0 | 0 | python,pygtk | 14,070,047 | 3 | false | 0 | 1 | You can use PyGobject instead of pygtk, and then setting a placeholder is a piece of cake:
entry.set_placeholder_text("some string") | 1 | 3 | 0 | How to create pygtk entry with placeholder like in HTML 5 input element? | Pygtk entry placeholder | 0.066568 | 0 | 0 | 981 |
2,504,386 | 2010-03-23T23:27:00.000 | 1 | 0 | 0 | 0 | python,django,django-models | 2,504,441 | 3 | false | 1 | 0 | Quoth my elementary chemistry teacher: "If you don't write it down, it didn't happen", therefore save logs in a file.
Since the log information is disjoint from your application data (it's meta-data, actually), keep them separate. You could log to a database table but it should be distinct from your model.
Text pickle data is difficult for humans to read, binary pickle data even more so; log in an easily parsed format and the data can be imported into analysis software easily. | 1 | 6 | 0 | I have various models of which I would like to keep track and collect statistical data.
The problem is how to store the changes throughout time.
I thought of various alternative:
Storing a log in a TextField, open it and update it every time the model is saved.
Alternatively pickle a list and store it in a TextField.
Save logs on hard drive.
What are your suggestions? | Keeping track of changes - Django | 0.066568 | 0 | 0 | 1,579 |
2,504,800 | 2010-03-24T01:31:00.000 | 19 | 0 | 1 | 1 | python,programming-languages,development-environment | 2,504,835 | 11 | true | 0 | 0 | Your system already has Python on it. Use the text editor or IDE of your choice; I like vim.
I can't tell you what third-party modules you need without knowing what kind of development you will be doing. Use apt as much as you can to get the libraries.
To speak to your edit:
This isn't minimalistic, like handing a .NET newbie notepad and a compiler: a decent text editor and the stdlib are all you really need to start out. You will likely need third-party libraries to develop whatever kind of applications you are writing, but I cannot think of any third-party modules all Python programmers will really need or want.
Unlke the .NET/Windows programming world, there is no one set of dev tools that stands above all others. Different people use different editors a whole lot. In Python, a module namespace is fully within a single file and project organization is based on the filesystem, so people do not lean on their IDEs as hard. Different projects use different version control software, which has been booming with new faces recently. Most of these are better than TFS and all are 1000 times better than SourceSafe.
When I want an interactive session, I use the vanilla Python interpreter. Various more fancy interpreters exist: bpython, ipython, IDLE. bpython is the least fancy of these and is supposed to be good about not doing weird stuff. ipython and IDLE can lead to strange bugs where code that works in them doens't work in normal Python and vice-versa; I've seen this first hand with IDLE.
For some of the tools you asked about and some others
In .NET you would use NUnit. In Python, use the stdlib unittest module. There are various third-party extensions and test runners, but unittest should suit you okay.
If you really want to look into something beyond this, get unittest2, a backport of the 2.7 version of unittest. It has incorporated all the best things from the third-party tools and is really neat.
In .NET you would use SQL Server. In Python, you may use PostgreSQL, MySQL, sqlite, or some other database. Python specifies a unified API for databases and porting from one to another typically goes pretty smoothly. sqlite is in the stdlib.
There are various Object Relational Models to make using databases more abstracted. SQLAlchemy is the most notable of these.
If you are doing network programming, get Twisted.
If you are doing numerical math, get numpy and scipy.
If you are doing web development, choose a framework. There are about 200000: Pylons, zope, Django, CherryPy, werkzeug...I won't bother starting an argument by recommending one. Most of these will happily work with various servers with a quick setting.
If you want to do GUI development, there are quite a few Python bindings. The stdlib ships with Tk bindings I would not bother with. There are wx bindings (wxpython), GTK+ bindings (pygtk), and two sets of Qt bindings. If you want to do native Windows GUI development, get IronPython and do it in .NET. There are win32 bindings, but they'll make you want to pull your hair out trying to use them directly. | 5 | 13 | 0 | I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.
What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.
I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.
Edit: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. I'd recommend Visual Studio, NUnit, SQL Server, etc. | How do I set up a Python development environment on Linux? | 1.2 | 0 | 0 | 15,576 |
2,504,800 | 2010-03-24T01:31:00.000 | 4 | 0 | 1 | 1 | python,programming-languages,development-environment | 2,504,896 | 11 | false | 0 | 0 | Since I'm accustomed to Eclipse, I find Eclipse + PyDev convenient for Python. For quick computations, Idle is great.
I've used Python on Windows and on Ubuntu, and Linux is much cleaner. | 5 | 13 | 0 | I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.
What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.
I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.
Edit: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. I'd recommend Visual Studio, NUnit, SQL Server, etc. | How do I set up a Python development environment on Linux? | 0.072599 | 0 | 0 | 15,576 |
2,504,800 | 2010-03-24T01:31:00.000 | 1 | 0 | 1 | 1 | python,programming-languages,development-environment | 2,506,982 | 11 | false | 0 | 0 | You don't need much. Python comes with "Batteries Included."
Visual Studio == IDLE. You already have it. If you want more IDE-like environment, install Komodo Edit.
NUnit == unittest. You already have it in the standard library.
SQL Server == sqlite. You already have it in the standard library.
Stop wasting time getting everything ready. It's already there in the basic Python installation.
Get to work.
Linux, BTW, is primarily a development environment. It was designed and built by developers for developers. Windows is an end-user environment which has to be supplemented for development.
Linux was originally focused on developers. All the tools you need are either already there or are part of simple yum or RPM installs. | 5 | 13 | 0 | I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.
What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.
I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.
Edit: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. I'd recommend Visual Studio, NUnit, SQL Server, etc. | How do I set up a Python development environment on Linux? | 0.01818 | 0 | 0 | 15,576 |
2,504,800 | 2010-03-24T01:31:00.000 | 2 | 0 | 1 | 1 | python,programming-languages,development-environment | 2,504,806 | 11 | false | 0 | 0 | Python (duh), setuptools or pip, virtualenv, and an editor. I suggest geany, but that's just me. And of course, any other Python modules you'll need. | 5 | 13 | 0 | I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.
What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.
I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.
Edit: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. I'd recommend Visual Studio, NUnit, SQL Server, etc. | How do I set up a Python development environment on Linux? | 0.036348 | 0 | 0 | 15,576 |
2,504,800 | 2010-03-24T01:31:00.000 | 0 | 0 | 1 | 1 | python,programming-languages,development-environment | 2,505,840 | 11 | false | 0 | 0 | Database: sqlite (inbuilt). You might want SQLAlchemy though.
GUI: tcl is inbuilt, but wxPython or pyQt are recommended.
IDE: I use idle (inbuilt) on windows, TextMate on Mac, but you might like PyDev. I've also heard good things about ulipad.
Numerics: numpy.
Fast inline code: lots of options. I like boost weave (part of scipy), but you could look into ctypes (to use dlls), Cython, etc.
Web server: too many options. Django (plus Apache) is the biggest.
Unit testing: inbuilt.
Pyparsing, just because.
BeautifulSoup (or another good HTML parser).
hg, git, or some other nice VC.
Trac, or another bug system.
Oh, and StackOverflow if you have any questions. | 5 | 13 | 0 | I'm a .NET developer who knows very little about Python, but want to give it a test drive for a small project I'm working on.
What tools and packages should I install on my machine? I'm looking for a common, somewhat comprehensive, development environment.
I'll likely run Ubuntu 9.10, but I'm flexible. If Windows is a better option, that's fine too.
Edit: To clarify, I'm not looking for the bare minimum to get a Python program to run. I wouldn't expect a newbie .NET dev to use notepad and a compiler. I'd recommend Visual Studio, NUnit, SQL Server, etc. | How do I set up a Python development environment on Linux? | 0 | 0 | 0 | 15,576 |
2,505,072 | 2010-03-24T03:05:00.000 | 1 | 0 | 0 | 0 | python,django,payment-gateway,payment-processing | 17,987,815 | 5 | false | 1 | 0 | Consider enabling more than one payment gateways. If you add only one, and this gateway fails for some reason you'll start losing money (actually happened to one of the persons I know). | 2 | 18 | 0 | I'm developing a web application that will require users to either make one time deposits of money into their account, or allow users to sign up for recurring billing each month for a certain amount of money.
I've been looking at various payment gateways, but most (if not all) of them seem complex and difficult to get working. I also see no real active Django projects which offer simple views for making payments.
Ideally, I'd like to use something like Amazon FPS, so that I can see online transaction logs, refund money, etc., but I'm open to other things.
I just want the EASIEST possible payment gateway to integrate with my site. I'm not looking for anything fancy, whatever does the job, and requires < 10 hours to get working from start to finish would be perfect.
I'll give answer points to whoever can point out a good one. Thanks!
EDIT: This is to accept payments in the US only. I don't need an international payment gateway. And it only needs to support US English. | What is the Simplest Possible Payment Gateway to Implement? (using Django) | 0.039979 | 0 | 0 | 23,610 |
2,505,072 | 2010-03-24T03:05:00.000 | 2 | 0 | 0 | 0 | python,django,payment-gateway,payment-processing | 2,505,692 | 5 | false | 1 | 0 | I've done successful integrations for both Google Checkout and PayPal ExpressCheckout in Django. Both services have stable, well-developed APIs, and neither one was too difficult to implement. There are good Python libraries already written to do the heavy lifting for you, too. | 2 | 18 | 0 | I'm developing a web application that will require users to either make one time deposits of money into their account, or allow users to sign up for recurring billing each month for a certain amount of money.
I've been looking at various payment gateways, but most (if not all) of them seem complex and difficult to get working. I also see no real active Django projects which offer simple views for making payments.
Ideally, I'd like to use something like Amazon FPS, so that I can see online transaction logs, refund money, etc., but I'm open to other things.
I just want the EASIEST possible payment gateway to integrate with my site. I'm not looking for anything fancy, whatever does the job, and requires < 10 hours to get working from start to finish would be perfect.
I'll give answer points to whoever can point out a good one. Thanks!
EDIT: This is to accept payments in the US only. I don't need an international payment gateway. And it only needs to support US English. | What is the Simplest Possible Payment Gateway to Implement? (using Django) | 0.07983 | 0 | 0 | 23,610 |
2,507,463 | 2010-03-24T12:11:00.000 | 0 | 0 | 0 | 0 | java,php,python,ruby | 2,512,975 | 8 | false | 1 | 0 | There are no clear cut winners when picking a web framework. Each platform you mentioned has its benefits and drawbacks (cost of hardware, professional support, community support, etc.). Depending on your time table, project requirements, and available hardware resources you are probably going to need some different answers.Personally, I would start your investigation with a platform where you and your team are most experienced.
Like many of the other posters I can only speak to what I'm actively using now, and in my case it is Java. If Java seems to match your projects requirements, you probably want to go with one of the newer frameworks with an active community. Currently Spring Web MVC, Struts2, and Stripes seem to be fairly popular. These frameworks are mostly, if not totally, independent of the persistence layer, but all integrate well with technologies like hibernate and jpa; although you have to do most, if not all, of the wiring yourself.
If you want to take the Java road there are also pre-built application stacks that take care of most of wiring issues for you. For an example you might want to look at Matt Raible's AppFuse. He has built an extensible starter application with many permutations of popular java technologies.
If you are interested in the JVM as a platform, you may also want to look at complete stack solutions like Grails, or tools that help you build your stack quickly like Spring Roo.
Almost all of the full stack solutions I've seen allow for integration with a legacy database schema. As long as your database is well designed, you should be able to map your tables. The mention of composite keys kind of scares me, but depending on your persistence technology this may or may not be an issue. Hibernate in Java/.NET supports mapping to composite keys, as does GORM in grails (built on hibernate). In almost all cases these mappings are discouraged, but people who build persistence frameworks know you can't always scorch earth and completely recreate your model. | 2 | 1 | 0 | A legacy web application written using PHP and utilizing MySql database needs to be rewritten completely. However, the existing database structure must not be changed at all.
I'm looking for suggestions on which framework would be most suitable for this task? Language candidates are Python, PHP, Ruby and Java.
According to many sources it might be challenging to utilize rails effectively with existing database. Also I have not found a way to automatically generate models out of the database.
With Django it's very easy to generate models automatically. However I'd appreciate first hand experience on its suitability to work with legacy DBs. The database in question contains all kinds of primary keys, including lots of composite keys.
Also I appreciate suggestions of other frameworks worth considering. | Web framework for an application utilizing existing database? | 0 | 1 | 0 | 1,525 |
2,507,463 | 2010-03-24T12:11:00.000 | 2 | 0 | 0 | 0 | java,php,python,ruby | 2,507,492 | 8 | false | 1 | 0 | I have very good experience with Django. Every time I needed it was up to the task for interfacing with existing database.
Autogenerated models are the start, as MySQL is not the strictest with its schema. Not that it will not work only that usually some of the db restrictions are held in app itself. | 2 | 1 | 0 | A legacy web application written using PHP and utilizing MySql database needs to be rewritten completely. However, the existing database structure must not be changed at all.
I'm looking for suggestions on which framework would be most suitable for this task? Language candidates are Python, PHP, Ruby and Java.
According to many sources it might be challenging to utilize rails effectively with existing database. Also I have not found a way to automatically generate models out of the database.
With Django it's very easy to generate models automatically. However I'd appreciate first hand experience on its suitability to work with legacy DBs. The database in question contains all kinds of primary keys, including lots of composite keys.
Also I appreciate suggestions of other frameworks worth considering. | Web framework for an application utilizing existing database? | 0.049958 | 1 | 0 | 1,525 |
2,508,861 | 2010-03-24T15:17:00.000 | 8 | 0 | 1 | 0 | python | 2,508,868 | 8 | false | 0 | 0 | int('243\r\n'.strip())
But that won't help you, if something else than a number is passed. Always put try, except and catch ValueError.
Anyway, this also works: int('243\n\r '), so maybe you don't even need strip.
EDIT:
Why don't you just write your own function, that will catch the exception and return a sane default and put into some utils module? | 2 | 10 | 0 | Does anybody have a quickie for converting an unsafe string to an int?
The string typically comes back as: '234\r\n' or something like that.
In this case I want 234. If '-1\r\n', I want -1. I never want the method to fail but I don't want to go so far as try, except, pass just to hide errors either (in case something extreme happens). | Python: Convert a string to an integer | 1 | 0 | 0 | 49,606 |
2,508,861 | 2010-03-24T15:17:00.000 | 0 | 0 | 1 | 0 | python | 2,509,234 | 8 | false | 0 | 0 | Under Python 3.0 (IDLE) this worked nicely
strObj = "234\r\n"
try:
#a=int(strObj)
except ValueError:
#a=-1
print(a)
>>234
If you're dealing with input you cannot trust, you never should anyway, then it's a good idea to use try, except, pass blocks to control exceptions when users provide incompatible data. It might server you better to think about try, except, pass structures as defensive measures for protecting data compatibility rather than simply hidding errors.
try:
a=int(strObj) #user sets strObj="abc"
except ValueError:
a=-1
if a != -1:
#user submitted compatible data
else:
#inform user of their error
I hope this helps. | 2 | 10 | 0 | Does anybody have a quickie for converting an unsafe string to an int?
The string typically comes back as: '234\r\n' or something like that.
In this case I want 234. If '-1\r\n', I want -1. I never want the method to fail but I don't want to go so far as try, except, pass just to hide errors either (in case something extreme happens). | Python: Convert a string to an integer | 0 | 0 | 0 | 49,606 |
2,510,158 | 2010-03-24T17:51:00.000 | 1 | 0 | 1 | 0 | python,ip-address,syslog,blacklist | 2,510,205 | 2 | false | 0 | 0 | For each line:
read the IP and attempt status
keep a dictionary by IP of amount of failed attempts
Then go over the dictionary:
print to file all IPs with 5 or more attempts
Python hints:
To read a file line by line: for line in open(filename)
Parsing the log line depends entirely on its format. Some useful Python tools are the split method of a string, and regular expressions
Keep a dictionary, i.e. ips[ip] is amount of attempts | 1 | 0 | 0 | Basically I have an authlog/syslog file with a list of log in attempts and IP addresses - I need to make a Python program that will create a txt file with all the IP addresses that have more than 5 failed login attempts - a sort of "blacklist".
So basically something like:
if "uniqueipaddress" and "authentication failure" appear more than 5 times, add uniqueipaddress to txt file.
Any help would be greatly appreciated - please try and make it simple as I am very, very inexperienced in programming in Python! Thanks. | Python - create blacklist file of IP addresses that have more than 5 failed login attempts in the authlog | 0.099668 | 0 | 0 | 1,998 |
2,510,755 | 2010-03-24T19:19:00.000 | 6 | 1 | 1 | 0 | python,algorithm | 2,510,928 | 8 | false | 0 | 0 | It sounds like what you want, is to treat alphabetical characters as a base-26 value between 0 and 1. When you have strings of different length (an example in base 10), say 305 and 4202, your coming out with a midpoint of 3, since you're looking at the characters one at a time. Instead, treat them as a floating point mantissa: 0.305 and 0.4202. From that, it's easy to come up with a midpoint of .3626 (you can round if you'd like).
Do the same with base 26 (a=0...z=25, ba=26, bb=27, etc.) to do the calculations for letters:
cat becomes 'a.cat' and doggie becomes 'a.doggie', doing the math gives cat a decimal value of 0.078004096, doggie a value of 0.136390697, with an average of 0.107197397 which in base 26 is roughly "cumcqo" | 1 | 8 | 0 | Suppose you take the strings 'a' and 'z' and list all the strings that come between them in alphabetical order: ['a','b','c' ... 'x','y','z']. Take the midpoint of this list and you find 'm'. So this is kind of like taking an average of those two strings.
You could extend it to strings with more than one character, for example the midpoint between 'aa' and 'zz' would be found in the middle of the list ['aa', 'ab', 'ac' ... 'zx', 'zy', 'zz'].
Might there be a Python method somewhere that does this? If not, even knowing the name of the algorithm would help.
I began making my own routine that simply goes through both strings and finds midpoint of the first differing letter, which seemed to work great in that 'aa' and 'az' midpoint was 'am', but then it fails on 'cat', 'doggie' midpoint which it thinks is 'c'. I tried Googling for "binary search string midpoint" etc. but without knowing the name of what I am trying to do here I had little luck.
I added my own solution as an answer | Average of two strings in alphabetical/lexicographical order | 1 | 0 | 0 | 2,674 |
2,510,903 | 2010-03-24T19:45:00.000 | 1 | 0 | 0 | 1 | python,django,google-app-engine,web-applications,tipfy | 2,512,079 | 6 | false | 1 | 0 | I'm still investigating, but I think webapp and tipfy will be a lighter framework than django. Right now, I am using just webapp and the cold start times are already too long. I want to use tipfy for sessions and keep everything else in webapp.
What are you trying to optimize for? Speed of development? Easy of programming? Obscure middleware? | 3 | 10 | 0 | which one are you using on google app engine?
what were the reasons behind your decision? | webapp, tipfy or django on google app engine | 0.033321 | 0 | 0 | 2,218 |
2,510,903 | 2010-03-24T19:45:00.000 | 1 | 0 | 0 | 1 | python,django,google-app-engine,web-applications,tipfy | 3,184,831 | 6 | false | 1 | 0 | I would still prefer Django for its structure and a high support available over internet for it and for the following reasons:
Webapp offcourse is light weight, but
Django comes with a nice structure
which saves a lots of time while
working on a large application.
Google app engine does provide a good
document for working with Webapp but Django has
a large community of programmers and
thus proves to be a better choice for
implementing some complex
applications.
Django provides a default admin
panel, which otherwise would need to
be created in Webapp, though Google
app provides an admin interface but
that is not equivalent of a full
fledged customizable admin panel.
Webapp itself follows Django for its templates. | 3 | 10 | 0 | which one are you using on google app engine?
what were the reasons behind your decision? | webapp, tipfy or django on google app engine | 0.033321 | 0 | 0 | 2,218 |
2,510,903 | 2010-03-24T19:45:00.000 | 4 | 0 | 0 | 1 | python,django,google-app-engine,web-applications,tipfy | 3,304,317 | 6 | false | 1 | 0 | Imho..
Django - the only part that's relevant is the templating and maybe the no rel..
Webapp - never tried it after
Tipfy - is what I'm using, seems to be more "pylons" like, has a basic apps/modules structure and lots of "helpers" which quite frankly should be in the google.appengine.api
Easy to implement templates and routing is nice. Your pretty much left on your own on how to use tipfy and how to structure the application. | 3 | 10 | 0 | which one are you using on google app engine?
what were the reasons behind your decision? | webapp, tipfy or django on google app engine | 0.132549 | 0 | 0 | 2,218 |
2,512,386 | 2010-03-25T00:24:00.000 | 78 | 0 | 0 | 0 | python,csv,merge,concatenation | 5,876,058 | 22 | false | 0 | 0 | Why can't you just sed 1d sh*.csv > merged.csv?
Sometimes you don't even have to use python! | 1 | 96 | 1 | Guys, I here have 200 separate csv files named from SH (1) to SH (200). I want to merge them into a single csv file. How can I do it? | how to merge 200 csv files in Python | 1 | 0 | 0 | 189,456 |
2,512,571 | 2010-03-25T01:20:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,memcached | 2,514,663 | 3 | false | 1 | 0 | If you cache a query, is there an
accepted method for ensuring that the
cache is cleared/updated when an
object stored in that query is
updated.
Typically you wrap your reads with a conditional to retrieve the value from the main DB if it's not in the cache. Just wrap your updates as well to fill the cache whenever you write the data. That's if you need the results to be as up to date as possible - if you're not so bothered about it being out of date just set an expiry time that is low enough for the application to have to re-request the data from the main DB often enough. | 2 | 2 | 0 | I am struggling to find a good tutorial or best practices document for the use of memcache in app engine.
I'm pretty happy with it on the level presented in the docs. Get an object by ID, checking memcache first, but I'm unclear on things like:
If you cache a query, is there an accepted method for ensuring that the cache is cleared/updated when an object stored in that query is updated.
What are the effects of using ReferenceProperties ? If a cache a Foo object with a Bar reference. Is my foo.bar in memcache too and in need of clearing down if it gets updated from some other part of my application.
I don't expect answers to this here (unless you are feeling particularly generous!), but pointers to things I could read would be very gratefully received. | Idiots guide to app engine and memcache | 0.197375 | 0 | 0 | 2,620 |
2,512,571 | 2010-03-25T01:20:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,memcached | 5,571,331 | 3 | false | 1 | 0 | About reference properties, let's say you have MainModel and RefModel with a reference property 'ref' that points to a MainModel instance. Whenever you cal ref_model.ref it does a datastore get operation and retrieves the object from datastore. It does not interact with memcache in any way. | 2 | 2 | 0 | I am struggling to find a good tutorial or best practices document for the use of memcache in app engine.
I'm pretty happy with it on the level presented in the docs. Get an object by ID, checking memcache first, but I'm unclear on things like:
If you cache a query, is there an accepted method for ensuring that the cache is cleared/updated when an object stored in that query is updated.
What are the effects of using ReferenceProperties ? If a cache a Foo object with a Bar reference. Is my foo.bar in memcache too and in need of clearing down if it gets updated from some other part of my application.
I don't expect answers to this here (unless you are feeling particularly generous!), but pointers to things I could read would be very gratefully received. | Idiots guide to app engine and memcache | 0 | 0 | 0 | 2,620 |
2,513,260 | 2010-03-25T05:27:00.000 | 2 | 0 | 1 | 0 | python,wxpython | 2,513,304 | 5 | false | 0 | 0 | You have given yourself an answer:
and feel pretty confident about
writing simple applications for it
go ahead and write more complex applications!
The issue here is that you do not feel challenged, and you assume that you are done with your basic learning. Just find what to do! Simplify a process (say, file management), retrieve data from Internet (say, the last 25 twitter posts about Python), consolidate your mail clients into a single command line application, etc.
The MOST productive thing you could do (assuming you really don't have problems of your own), is to find an open source Python project (say, Matplotlib) and become a contributor. You will quickly realize that Python is beautiful, but it is a beast nevertheless.
If you still feel unchallenged, contact me and I will send you a ton of stuff to code which, believe me, is not easy.
Good luck! | 2 | 2 | 0 | Well, I have read several user guides and watched dozens and dozens of video tutorials on how to program with Python, and feel pretty confident about writing simple applications for it. My main point in my question is, where would I be able to learn more advanced programming knowledge about Python? | Once I know the basic elements and syntax of Python, what should I do? | 0.07983 | 0 | 0 | 243 |
2,513,260 | 2010-03-25T05:27:00.000 | 1 | 0 | 1 | 0 | python,wxpython | 2,561,525 | 5 | false | 0 | 0 | my favorite way in learning python is ( learning through projects ).
put yourself a goal , like a software for example ( 6 years ago when i started to learn python i picked a messenger . so i had to read more about sockets, network programming , and interfaces libraries ) . start with it , look for examples and resources to learn more . then do it.
the key is NOT TO GIVE UP and keep trying and searching until you make it .
. this can be fastest and the most efficient way in learning any programming language .
good luck ;) | 2 | 2 | 0 | Well, I have read several user guides and watched dozens and dozens of video tutorials on how to program with Python, and feel pretty confident about writing simple applications for it. My main point in my question is, where would I be able to learn more advanced programming knowledge about Python? | Once I know the basic elements and syntax of Python, what should I do? | 0.039979 | 0 | 0 | 243 |
2,513,786 | 2010-03-25T07:45:00.000 | 1 | 0 | 0 | 0 | python,wxpython,copy,matplotlib | 3,120,753 | 1 | false | 0 | 1 | I'm not familiar with the inner workings, but could easily imagine how disposing of a frame damages the figure data. Is it expensive to draw? Otherwise I'd take the somewhat chickenish approach of simply redrawing it ;) | 1 | 8 | 1 | I have FigureCanvasWxAgg instance with a figure displayed on a frame. If user clicks on the canvas another frame with a new FigureCanvasWxAgg containing the same figure will be shown. By now closing the new frame can result in destroying the C++ part of the figure so that it won't be available for the first frame.
How can I save the figure? Python deepcopy from copy module does't work in this case.
Thanks in advance. | How to copy matplotlib figure? | 0.197375 | 0 | 0 | 1,759 |
2,517,367 | 2010-03-25T16:29:00.000 | 1 | 0 | 1 | 0 | .net,ironpython,dynamic-language-runtime | 2,519,403 | 1 | true | 0 | 0 | There's no way to turn this off without modifying IronPython. | 1 | 1 | 0 | When I create an instance of my C# class in IronPython with named parameters to the constructor, it is setting properties corresponding to the names of the parameters. I wish to disable this behavior so I can have better control on the order the properties are evaluated.
Is this possible? | Ironpython - Named parameters to constructor | 1.2 | 0 | 0 | 413 |
2,518,730 | 2010-03-25T19:29:00.000 | 2 | 0 | 0 | 0 | python,numpy | 2,521,903 | 5 | false | 0 | 0 | I would say go with meshgrid or mgrid, in particular if you need non-integer coordinates. I'm surprised that Numpy's broadcasting rules would be more efficient, as meshgrid was designed especially for the problem that you want to solve. | 1 | 4 | 1 | I want to create a list containing the 3-D coords of a grid of regularly spaced points, each as a 3-element tuple. I'm looking for advice on the most efficient way to do this.
In C++ for instance, I simply loop over three nested loops, one for each coordinate. In Matlab, I would probably use the meshgrid function (which would do it in one command). I've read about meshgrid and mgrid in Python, and I've also read that using numpy's broadcasting rules is more efficient. It seems to me that using the zip function in combination with the numpy broadcast rules might be the most efficient way, but zip doesn't seem to be overloaded in numpy. | A 3-D grid of regularly spaced points | 0.07983 | 0 | 0 | 1,877 |
2,518,753 | 2010-03-25T19:32:00.000 | 1 | 0 | 1 | 0 | python | 2,518,794 | 5 | false | 0 | 0 | You could simply use a number, and decide on a mapping between number and "card". For example:
number MOD 13 = face value (after a +1)
number DIV 13 = suit | 1 | 17 | 0 | What is the best way to store the cards and suits in python so that I can hold a reference to these values in another variable?
For example, if I have a list called hand (cards in players hand), how could I hold values that could refer to the names of suits and values of specific cards, and how would these names and values of suits and cards be stored? | best way to implement a deck for a card game in python | 0.039979 | 0 | 0 | 27,823 |
2,518,814 | 2010-03-25T19:41:00.000 | 4 | 0 | 1 | 0 | ironpython,distribution | 2,522,814 | 1 | true | 0 | 0 | I would not try to find IronPython - I would append all necessary IronPython runtime files directly to your application. Then it is 100% foolproof :-) | 1 | 3 | 0 | I'm thinking of developing a small application using IronPython, however I want to distribute my app to non-techies and so ideally I want to be able to give them a standard shortcut to my application along with the instructions that they need to install IronPython first.
If possible I even want my shortcut to detect if IronPython is not present and display a suitable warning if this is the case (which I can do using a simple VbScript)
The trouble is that IronPython doesn't place itself in the %PATH% environment variable, and so if IronPython is installed to a nonstandard location my shortcut don't work.
Now I could also tell my users "If you install IronPython to a different location you need to go and edit this shortcut and...", but this is all getting far too technical for my target audience.
Is there any foolproof way of distributing my IronPython dependent app? | Distributing IronPython applications | 1.2 | 0 | 0 | 986 |
2,519,598 | 2010-03-25T21:37:00.000 | 3 | 0 | 0 | 0 | python,c,telnet | 2,525,924 | 9 | false | 0 | 0 | While telnet is almost just a socket tied to a terminal it's not quite. I believe that there can be some control characters that get passed shortly after the connection is made. If your device is sending some unexpected control data then it may be confusing your program.
If you haven't already, go download wireshark (or tshark or tcpdump) and monitor your connection. Wireshark (formerly ethereal) is cross platform and pretty easy to use for simple stuff. Filter with tcp.port == 23 | 3 | 9 | 0 | HI,
I have a device that exposes a telnet interface which you can log into using a username and password and then manipulate the working of the device.
I have to write a C program that hides the telnet aspect from the client and instead provides an interface for the user to control the device.
What would be a good way to proceed. I tried writing a simple socket program but it stops at the login prompt. My guess is that i am not following the TCP protocol.
Has anyone attempted this, is there an opensource library out there to do this?
Thanks
Addition:
Eventually i wish to expose it through a web api/webservice. The platform is linux. | Writing a telnet client | 0.066568 | 0 | 1 | 18,409 |
2,519,598 | 2010-03-25T21:37:00.000 | 4 | 0 | 0 | 0 | python,c,telnet | 2,519,786 | 9 | false | 0 | 0 | telnet's protocol is pretty straightforward... you just create a TCP connection, and send and receive ASCII data. That's pretty much it.
So all you really need to do is create a program that connects via TCP, then reads characters from the TCP socket and parses it to update the GUI, and/or writes characters to the socket in response to the user manipulating controls in the GUI.
How you would implement that depends a lot on what software you are using to construct your interface. On the TCP side, a simple event loop around select() would be sufficient. | 3 | 9 | 0 | HI,
I have a device that exposes a telnet interface which you can log into using a username and password and then manipulate the working of the device.
I have to write a C program that hides the telnet aspect from the client and instead provides an interface for the user to control the device.
What would be a good way to proceed. I tried writing a simple socket program but it stops at the login prompt. My guess is that i am not following the TCP protocol.
Has anyone attempted this, is there an opensource library out there to do this?
Thanks
Addition:
Eventually i wish to expose it through a web api/webservice. The platform is linux. | Writing a telnet client | 0.088656 | 0 | 1 | 18,409 |
2,519,598 | 2010-03-25T21:37:00.000 | 1 | 0 | 0 | 0 | python,c,telnet | 2,521,858 | 9 | false | 0 | 0 | Unless the application is trivial, a better starting point would be to figure out how you're going to create the GUI. This is a bigger question and will have more impact on your project than how exactly you telnet into the device. You mention C at first, but then start talking about Python, which makes me believe you are relatively flexible in the matter.
Once you are set on a language/platform, then look for a telnet library -- you should find something reasonable already implemented. | 3 | 9 | 0 | HI,
I have a device that exposes a telnet interface which you can log into using a username and password and then manipulate the working of the device.
I have to write a C program that hides the telnet aspect from the client and instead provides an interface for the user to control the device.
What would be a good way to proceed. I tried writing a simple socket program but it stops at the login prompt. My guess is that i am not following the TCP protocol.
Has anyone attempted this, is there an opensource library out there to do this?
Thanks
Addition:
Eventually i wish to expose it through a web api/webservice. The platform is linux. | Writing a telnet client | 0.022219 | 0 | 1 | 18,409 |
2,519,670 | 2010-03-25T21:51:00.000 | 2 | 0 | 1 | 0 | python,regex,alphanumeric | 44,874,007 | 6 | false | 0 | 0 | I would consider this for a valid username:
1) Username must be 6-30 characters long
2) Username may only contain:
Uppercase and lowercase letters
Numbers from 0-9 and
Special characters _ - .
3) Username may not:
Begin or finish with characters _ - .
Have more than one sequential character _ - . inside
This would be example of usage:
if re.match(r'^(?![-._])(?!.*[_.-]{2})[\w.-]{6,30}(?<![-._])$',username) is not None: | 1 | 7 | 0 | I looked and searched and couldn't find what I needed although I think it should be simple (if you have any Python experience, which I don't).
Given a string, I want to verify, in Python, that it contains ONLY alphanumeric characters: a-zA-Z0-9 and . _ -
examples:
Accepted:
bill-gates
Steve_Jobs
Micro.soft
Rejected:
Bill gates -- no spaces allowed
me@host.com -- @ is not alphanumeric
I'm trying to use:
if re.match("^[a-zA-Z0-9_.-]+$", username) == True:
But that doesn't seem to do the job... | Python code to use a regular expression to make sure a string is alphanumeric plus . - _ | 0.066568 | 0 | 0 | 15,328 |
2,519,706 | 2010-03-25T21:56:00.000 | 1 | 0 | 0 | 1 | python,linux,logging,permissions | 2,519,800 | 2 | false | 0 | 0 | I see you are on linux,
Depending on which filesystem you are using, you may be able to use the chattr command. You can make files that are append only by setting the a attribute | 1 | 0 | 0 | I am writing a python script that needs to make a log entry whenever it's invoked. The log created by the script must not be changeable by the user (except root) who invoked the script. I tried the syslog module and while this does exactly what I want in terms of file permissions, I need to be able to put the resulting log file in an arbitrary location. How would I go about doing this? | Creating Read-only logs with python | 0.099668 | 0 | 0 | 414 |
2,520,144 | 2010-03-25T23:22:00.000 | 1 | 0 | 0 | 0 | python,django,openid | 2,520,867 | 1 | true | 1 | 0 | Are you supplying an email address or URL? OpenID needs a URL and *******@gmail.com is an email address. | 1 | 0 | 0 | I get the following error when attempting to use django-openid-auth OpenID discovery error: No usable OpenID services found for *******@gmail.com
I have followed the instructions that come with it, though it seems there is something I am missing. the installation is on my localhost. | Django OpenID django-openid-auth Login Error | 1.2 | 0 | 0 | 577 |
2,521,558 | 2010-03-26T06:54:00.000 | 1 | 0 | 1 | 0 | python,performance,if-statement | 2,521,596 | 3 | false | 0 | 0 | I'm with Thilo: I think it should be pretty cheap.
If you really care, you should time the code and find out whether the slight overhead is unacceptable. I suspect not. | 2 | 5 | 0 | I have a division operation inside a cycle that repeats many times. It so happens that in the first few passes through the loop (more or less first 10 loops) the divisor is zero. Once it gains value, a div by zero error is not longer possible.
I have an if condition to test the divisor value in order to avoid the div by zero, but I am wondering that there is a performance impact that evaluating this if will have for each run in subsequent loops, especially since I know it's of no use anymore.
How should this be coded? in Python? | Avoid IF statement after condition has been met | 0.066568 | 0 | 0 | 1,717 |
2,521,558 | 2010-03-26T06:54:00.000 | 9 | 0 | 1 | 0 | python,performance,if-statement | 2,521,564 | 3 | false | 0 | 0 | Don't worry. An if (a != 0) is cheap.
The alternative (if you really want one) could be to split the loop into two, and exit the first one once the divisor gets its value. But that sounds like it would make the code unnecessarily complex (difficult to read). | 2 | 5 | 0 | I have a division operation inside a cycle that repeats many times. It so happens that in the first few passes through the loop (more or less first 10 loops) the divisor is zero. Once it gains value, a div by zero error is not longer possible.
I have an if condition to test the divisor value in order to avoid the div by zero, but I am wondering that there is a performance impact that evaluating this if will have for each run in subsequent loops, especially since I know it's of no use anymore.
How should this be coded? in Python? | Avoid IF statement after condition has been met | 1 | 0 | 0 | 1,717 |
2,522,774 | 2010-03-26T11:16:00.000 | 2 | 0 | 0 | 0 | python,django | 2,522,807 | 3 | false | 1 | 0 | request.env['HTTP_USER_AGENT'] will give the user agent string the browser sent. | 2 | 1 | 0 | in server side, not browser. | Is it possible to detect the browser version from Django server side? | 0.132549 | 0 | 0 | 948 |
2,522,774 | 2010-03-26T11:16:00.000 | 1 | 0 | 0 | 0 | python,django | 2,588,289 | 3 | true | 1 | 0 | Unfortunately request.env won't work.
However, you can get it through request.META.get("HTTP_USER_AGENT") | 2 | 1 | 0 | in server side, not browser. | Is it possible to detect the browser version from Django server side? | 1.2 | 0 | 0 | 948 |
2,525,002 | 2010-03-26T16:40:00.000 | 1 | 0 | 1 | 0 | python,ascii,coda | 2,525,363 | 1 | true | 0 | 0 | Python uses the 7-bit ASCII character set for program text. So all you need to do is convert your program to ASCII by going to text > convert to ASCII. Any bad characters will automatically be removed. If you want to specifically know which characters were the bad ones, you can use diff to compare changed and unchanged versions. | 1 | 1 | 0 | Sometimes I get errors while coding, because of typing some combination of keys (eg. ALT + SHIFT + SQUARE BRACKET) in a wrong way. So I get Syntax Error in Python, but I can't see where the illegal character is, 'cause Coda do not show it to me. Any solution? | How can I catch non valid ASCII characters in Panic Coda? | 1.2 | 0 | 0 | 443 |
2,525,518 | 2010-03-26T17:50:00.000 | 7 | 1 | 0 | 0 | python,c,code-translation | 2,525,638 | 4 | false | 0 | 0 | There's a fundamental question here: is the intent to basically create a Python compiler that uses C as a back-end, or to convert the program to C and maintain the C afterward?
Writing a compiler that produces (really ugly) C as its output probably isn't trivial -- a compiler rarely is, and generating code for Python will be more difficult than for a lot of other languages (dynamic typing, in particular, is hard to compile, at least to very efficient output). OTOH, at least the parser will be a lot easier than for some languages.
If by "translating", you mean converting Python to C that's readable and maintainable, that's a whole different question -- it's substantially more difficult, to put it mildly. Realistically, I doubt any machine translation will be worth much -- there are just too large of differences in how you normally approach problems in Python and C for there to be much hope of a decent machine translation. | 1 | 11 | 0 | I was asked to write a code translator that would take a Python program and produce a C program. Do you have any ideas how could I approach this problem or is it even possible? | Writing code translator from Python to C? | 1 | 0 | 0 | 11,985 |
2,526,110 | 2010-03-26T19:25:00.000 | 1 | 1 | 0 | 0 | python,security,authentication,login | 2,526,606 | 4 | false | 0 | 0 | As for how to protect the client... The most realistic thing is to say that you don't. When you're writing the server code, never trust any data that the client sends you. Never give the client any information you don't want the player to have.
In some games, like chess (or really anything turn-based), that actually works pretty well, because it's very easy for the server to verify that the move passed in by the client is a legal move.
In other games, those restrictions aren't so practical, and then I don't know what you'd do, from a code perspective. I'd try to shift the problem to a social one at that point: Are the other players people you'd trust to bring their own dice to your gaming table? If not, can you play with someone else? | 3 | 4 | 0 | First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password.
I was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?
The main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.
I realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks. | Game login authentication and security | 0.049958 | 0 | 0 | 1,320 |
2,526,110 | 2010-03-26T19:25:00.000 | 1 | 1 | 0 | 0 | python,security,authentication,login | 2,526,532 | 4 | false | 0 | 0 | The simple answer to how to protect the password going over the wire, replay attacks, and message tampering is: use SSL. Yes, there are other things you can do with challenge-response authentication schemes for the login part of it, but it sounds like you really want the whole channel protected anyway. Use SSL at the socket layer and then you don't have to do anything else complicated with how you send your credentials. | 3 | 4 | 0 | First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password.
I was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?
The main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.
I realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks. | Game login authentication and security | 0.049958 | 0 | 0 | 1,320 |
2,526,110 | 2010-03-26T19:25:00.000 | 1 | 1 | 0 | 0 | python,security,authentication,login | 2,526,148 | 4 | false | 0 | 0 | This is a tough problem, because the code runs on the client. The replay problem can be solved by using a challenge by letting the server sending a random token which the client adds to the string to be encrypted. This way, the password string will be different each time, and replaying the encrypted string doesn't work (as the server checks if the encrypted password has the last sent token)
The problem is that the encryption key has to be stored on the client, and it's possible to retrieve that key. | 3 | 4 | 0 | First off I will say I am completely new to security in coding. I am currently helping a friend develop a small game (in Python) which will have a login server. I don't have much knowledge regarding security, but I know many games do have issues with this. Everything from 3rd party applications (bots) to WPE packet manipulation. Considering how small this game will be and the limited user base, I doubt we will have serious issues, but would like to try our best to limit problems. I am not sure where to start or what methods I should use, or what's worth it. For example, sending data to the server such as login name and password.
I was told his information should be encrypted when sending, so in-case someone was viewing it (with whatever means), that they couldn't get into the account. However, if someone is able to capture the encrypted string, wouldn't this string always work since it's decrypted server side? In other words, someone could just capture the packet, reuse it, and still gain access to the account?
The main goal I am really looking for is to make sure the players are logging into the game with the client we provide, and to make sure it's 'secure' (broad, I know). I have looked around at different methods such as Public and Private Key encryption, which I am sure any hex editor could eventually find. There are many other methods that seem way over my head at the moment and leave the impression of overkill.
I realize nothing is 100% secure. I am just looking for any input or reading material (links) to accomplish the main goal stated above. Would appreciate any help, thanks. | Game login authentication and security | 0.049958 | 0 | 0 | 1,320 |
2,526,273 | 2010-03-26T19:48:00.000 | 0 | 1 | 0 | 0 | python,pyinotify | 2,526,820 | 1 | false | 0 | 0 | If you're going to watch only a few files in a huge tree, it makes sense to watch individual files. On the other hand, if you're going to watch almost all files in the tree, watching the entire tree instead makes sense. To know the point of turn exactly, you must benchmark both to see which one performs better. | 1 | 0 | 0 | I have a very large directory tree I am wanting pyInotify to watch.
Is it better to have pyInotify watch the entire tree or is it better to have a number of watches reporting changes to specific files ?
Thanks | pyInotify performance | 0 | 0 | 0 | 522 |
2,526,458 | 2010-03-26T20:17:00.000 | 1 | 0 | 0 | 0 | python,error-handling,pylons | 2,526,649 | 3 | false | 1 | 0 | I use formencode @validate decorator. It is possible to write custom validator for it but the problem with handling exceptions that occur in the model after validation still exists.
You could write custom action decorator similar to formencode one which will handle your model exceptions and populate c.form_errors. | 1 | 3 | 0 | What is the proper way to handle errors with Python + Pylons?
Say a user sets a password via a form that, when passed to a model class via the controller, throws an error because it's too short. How should that error be handled so that an error message gets displayed on the web page rather than the entire script terminating to an error page?
Should there be any error handling in the controller itself?
I hope I am explaining myself clearly.
Thank you. | Error handling with Python + Pylons | 0.066568 | 0 | 0 | 698 |
2,526,632 | 2010-03-26T20:46:00.000 | 1 | 0 | 0 | 1 | python,debian,binding | 2,526,648 | 5 | false | 0 | 0 | The python-dev package needs to be installed. | 1 | 3 | 0 | I'm trying to compile a Python binding, but I'm unable to find the python.h header on debian. Which package should I install? | Compiling a Python binding on Linux | 0.039979 | 0 | 0 | 772 |
2,526,681 | 2010-03-26T20:55:00.000 | 0 | 0 | 0 | 1 | java,python,xml,macos,xslt | 2,541,765 | 8 | false | 1 | 0 | I have used Saxon 6.5 for years for command line transformations. (Java, XSLT 1)
An excellent fallback if a native solution is not available. | 1 | 15 | 0 | I am on OSX Snow Leopard (10.6.2) I can install anything I need to. I would preferably like a Python or Java solution. I have searched on Google and found lots of information on writing my own program to do this, but this is a just a quick and dirty experiment so I don't want to invest a lot of time on writing a bunch of code to do this, I am sure someone else has done this already.
This is off-topic now, do not use this question as an example of why your recommendations request is on topic, it is not. I apologize, but my Google-Foo was failing me the day I asked this 4 years ago! | I need a simple command line program to transform XML using an XSL Stylesheet | 0 | 0 | 0 | 23,093 |
2,526,815 | 2010-03-26T21:16:00.000 | 2 | 0 | 0 | 0 | python,c,algorithm,calendar,astronomy | 2,597,088 | 8 | false | 0 | 0 | If you don't need high accuracy, you can always (ab)use a lunar (or lunisolar) calendar class (e.g., HijriCalendar or ChineseLunisolarCalendar in Microsoft .NET) to calculate the (approximate) moon phase of any date, as the calendar's "day-of-month" property, being a lunar (or lunisolar) calendar day, always corresponds to the moon phase (e.g., day 1 is the new moon, day 15 is the full moon, etc.) | 1 | 41 | 0 | Does anyone know an algorithm to either calculate the moon phase or age on a given date or find the dates for new/full moons in a given year?
Googling tells me the answer is in some Astronomy book, but I don't really want to buy a whole book when I only need a single page.
Update:
I should have qualified my statement about googling a little better. I did find solutions that only worked over some subset of time (like the 1900's); and the trig based solutions that would be more computationally expensive than I'd like.
S Lott in his Python book has several algorithms for calculating Easter on a given year, most are less than ten lines of code and some work for all days in the Gregorian calendar. Finding the full moon in March is a key piece of finding Easter so I figured there should be an algorithm that doesn't require trig and works for all dates in the Gregorian calendar. | Moon / Lunar Phase Algorithm | 0.049958 | 0 | 0 | 43,689 |
2,527,173 | 2010-03-26T22:28:00.000 | 6 | 0 | 0 | 1 | python,mongodb,cassandra,couchdb,nosql | 2,528,683 | 2 | true | 0 | 0 | Cassandra supports map reduce since version 0.6. (Current stable release is 0.5.1, but go ahead and try the new map reduce functionality in 0.6.0-beta3) To get started I recommend to take a look at the word count map reduce example in 'contrib/word_count'. | 1 | 4 | 1 | Since Cassandra doesn't have MapReduce built in yet (I think it's coming in 0.7), is it dumb to try and MapReduce with my Python client or should I just use CouchDB or Mongo or something?
The application is stats collection, so I need to be able to sum values with grouping to increment counters. I'm not, but pretend I'm making Google analytics so I want to keep track of which browsers appear, which pages they went to, and visits vs. pageviews.
I would just atomically update my counters on write, but Cassandra isn't very good at counters either.
May Cassandra just isn't the right choice for this?
Thanks! | Is Using Python to MapReduce for Cassandra Dumb? | 1.2 | 0 | 0 | 1,625 |
2,527,867 | 2010-03-27T02:10:00.000 | -1 | 1 | 0 | 0 | python,perl,groovy | 2,529,182 | 4 | false | 1 | 0 | First, it's important to note that it is very hard to convince someone they're wrong.
He's advocating bash scripts and Perl,
due to their universality and
simplicity
Bash scripts are not simple. The bash programming model is really complex and unfriendly. if statements and expressions, in particular are horrifying.
Perl may or may not be simple.
Bash is universal. Perl, however, is exactly as universal as Python. Python is pre-installed in almost all Linux distributions. So that argument is specious.
The "universality" of bash, Perl and python is exactly the same. The "simplicity", however, is not the same. You won't find it easy to to "prove" or "convince" anyone of this once they've already pronounced Perl as simple.
The Situation.
If the boss is advocating Perl, and Perl is not the answer, you will find it is very hard to convince someone they're wrong, making this effort nearly impossible.
If the boss was just throwing out ideas, then this is just difficult.
Quick Hack.
An easy thing you can do is to attempt head-to-head comparisons of Python and Perl for some randomly-chosen jobs. You can then have a code walkthrough to demonstrate the relative opacity of Perl compared with the relative clarity of Python.
Even this is fraught with terrible dangers.
Some folks really think code golf is important. Python loses at code golf. Perl wins. There's nothing worse than "Angry Co-worker with Perl Bias" who will kill you with code-golf solutions that -- because they're smaller -- can baffle management into thinking that they're clearer or "better" on some arbitrary scale.
Some folks really think explicit is "wordy" and bad. Python often loses because the assumptions are stated as actual parameter values. Some folks can (and do) complain at having to actually write things down. Read Stack Overflow for all of the Python questions where someone wants to make the try: block go away in a puff of assumptions.
If you choose random problems, you may -- accidentally -- chose something for which there's an existing piece of Perl or Python that can be downloaded and installed. A language can win just through an accident of the draw. Rather than a more in-depth comparison of language features.
Best Bet
The best you can do is the following.
Identify what folks value. You can call these "non-functional" requirements. These are quality factors. What are the foundational, core principles? Open, Accessible, Transferrable Skills, Simplicity, Cleanliness, Honesty, Integrity, Thriftiness, Reverence, Patience, Hard Work, A Sense of Perspective, Reef the Main in Winds over 20 kn, etc. This is hard. No sympathy here.
Identify the technical use cases. These are "functional" requirements. Which bits of glue and integration there are? This is hard, also. Requirements erupt of out of the woodwork when you do this. Also, when you have a Perl bigot on the team, numerous non-functional requirements will pile into this area. Your manager -- who proposed Perl -- may be the Perl bigot, and the use cases may be difficult to collect in the presence of a Perl bigot.
Identify how (a) Perl + Bash vs. (b) Python vs. (c) Java fit this core values and the functional requirements. Note that using Python means you do not need to use Bash as much. My preference, BTW, is to pare Bash down to the rock-bottom minimum.
This is a big, difficult job. It's hard to short-cut. If you find that Perl is not the answer and the Perl bigot you need to convince is the manager who proposed Perl in the first place, you may find that convincing someone that they're wrong is very hard.
Edit. I am aware that I am forbidden from using the string "Perl Bigot" to describe the manager's potential level of bias toward Perl. I, however, insist on using "Perl Bigot" to describe the manager who proposed Perl. The question provides no information on which to change this. The worst case is that (a) the manager is the Perl Bigot and (b) Perl is not the answer. | 2 | 4 | 0 | I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release notes generator).
Most of the time, our team just writes little plugins for larger apps (ex: customize workflows in Anthill), long-term utility scripts (package up a release for QA), or things like Perforce triggers (don't let people check into a specific branch unless their change description includes a bug number; authenticate against Active Directory instead of Perforce's internal passwords). That's about the scale of our problems, although we sometimes tackle something slightly more sizable.
My boss, who is reasonably technical, has asked us to standardize on one or two languages so we can more easily substitute for each other. He's advocating bash scripts and Perl, due to their universality and simplicity. I can see his point--we mostly do "glue", so why not use "glue" languages rather than saddle ourselves with something designed for much larger projects? Since some of the tools we work with are Java-based, we do need to use something that speaks JVM sometimes. (The path of least resistance for these projects is BeanShell and Groovy.) I feel a tremendous itch toward language advocacy, but I'm trying to avoid saying "We should use Python 'cause I like it and Perl is gross."
Instead, I'm trying to come up with a good approach to defining our problem set: what problems do we solve with scripts? Would we benefit from a library of common functions by our team, or are most of our projects more isolated? What is it reasonable to expect my co-workers to learn? What languages give us the most ease of development and ease of modification?
Can you folks suggest some useful ways to approach this problem, both for my own thinking process and to help me facilitate some brainstorming among my coworkers? | Standardizing a Release/Tools group on a specific language | -0.049958 | 0 | 0 | 196 |
2,527,867 | 2010-03-27T02:10:00.000 | 4 | 1 | 0 | 0 | python,perl,groovy | 2,527,917 | 4 | false | 1 | 0 | Google standardized on Python for such tasks (and many more) a bit before I joined the company; as far as I know, huge advantages such as Python's great implementations on the JVM and .NET didn't even play a role in the decision -- it was all about readability. At the time (and to some extent, even now) the theory at Google was that every engineer must be able, at need, to tweak every part of the codebase -- including of course build scripts, spiders (which were in Python at the time), and so forth. Demanding of engineers already proficient in C++ and Java to learn many more "scripting" languages (Python, Perl, Bash, Awk, Sed, and so forth) was simply unconsciounable: one had to be selected. Given that constraint, Python was the clear choice (under other constraints, Perl might also have been -- but I can't see the inevitable mix of Bash, Awk and Sed ever competing on such grounds!_) -- and that's how I ended up working there, a bit later;-).
Given that the overall potential of Python vs Ruby vs Perl vs PHP vs Bash + Awk + Sed vs ... is roughly equal, picking one is clearly a winner -- and Python has clean readability, strong implementations on JVM and .NET as big vigorishes. Seriously, I can only think of Javascript (inevitable for client-side work, now rich with strong implementations such as V8) as a possible "competitor" (unfortunately, JS inevitably carries on a lot of baggage for backwards compatibility -- unless you can use a use strict;-like constraint to help on that, it must be an important downside). | 2 | 4 | 0 | I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release notes generator).
Most of the time, our team just writes little plugins for larger apps (ex: customize workflows in Anthill), long-term utility scripts (package up a release for QA), or things like Perforce triggers (don't let people check into a specific branch unless their change description includes a bug number; authenticate against Active Directory instead of Perforce's internal passwords). That's about the scale of our problems, although we sometimes tackle something slightly more sizable.
My boss, who is reasonably technical, has asked us to standardize on one or two languages so we can more easily substitute for each other. He's advocating bash scripts and Perl, due to their universality and simplicity. I can see his point--we mostly do "glue", so why not use "glue" languages rather than saddle ourselves with something designed for much larger projects? Since some of the tools we work with are Java-based, we do need to use something that speaks JVM sometimes. (The path of least resistance for these projects is BeanShell and Groovy.) I feel a tremendous itch toward language advocacy, but I'm trying to avoid saying "We should use Python 'cause I like it and Perl is gross."
Instead, I'm trying to come up with a good approach to defining our problem set: what problems do we solve with scripts? Would we benefit from a library of common functions by our team, or are most of our projects more isolated? What is it reasonable to expect my co-workers to learn? What languages give us the most ease of development and ease of modification?
Can you folks suggest some useful ways to approach this problem, both for my own thinking process and to help me facilitate some brainstorming among my coworkers? | Standardizing a Release/Tools group on a specific language | 0.197375 | 0 | 0 | 196 |
2,528,283 | 2010-03-27T05:46:00.000 | 16 | 0 | 1 | 0 | python,mercurial | 2,528,509 | 7 | false | 0 | 0 | Do not store .pyc files in the repository.
Automatize .pyc delete with: find . -name '*.pyc' -delete
While develop use -B argument in Python. | 2 | 15 | 0 | (I foresaw this problem might happen 3 months ago, and was told to be diligent to avoid it. Yesterday, I was bitten by it, hard, and now that it has cost me real money, I am keen to fix it.)
If I move one of my Python source files into another directory, I need to remember to tell Mercurial that it moved (hg move).
When I deploy the new software to my server with Mercurial, it carefully deletes the old Python file and creates it in the new directory.
However, Mercurial is unaware of the pyc file in the same directory, and leaves it behind. The old pyc is used preferentially over new python file by other modules in the same directory.
What ensues is NOT hilarity.
How can I persuade Mercurial to automatically delete my old pyc file when I move the python file? Is there another better practice? Trying to remember to delete the pyc file from all the Mercurial repositories isn't working. | Automatically deleting pyc files when corresponding py is moved (Mercurial) | 1 | 0 | 0 | 7,805 |
2,528,283 | 2010-03-27T05:46:00.000 | 6 | 0 | 1 | 0 | python,mercurial | 2,528,297 | 7 | false | 0 | 0 | You need:
1) A real deployment infrastructure, even if it's just a shell script, which does everything. Cloning/checking out an updated copy from source control is not a deployment strategy.
2) Any deployment system should completely clean the directory structure. My usual preference is that each deployment happens to a new directory named with a date+timestamp, and a symlink (with a name like "current") is updated to point to the new directory. This gives you breadcrumbs on each server should something go wrong.
3) To fix whatever is running the Python code. New .py source files should always take precedence over cached .pyc files. If that is not the behavior you are seeing, it is a bug, and you need to figure out why it is happening. | 2 | 15 | 0 | (I foresaw this problem might happen 3 months ago, and was told to be diligent to avoid it. Yesterday, I was bitten by it, hard, and now that it has cost me real money, I am keen to fix it.)
If I move one of my Python source files into another directory, I need to remember to tell Mercurial that it moved (hg move).
When I deploy the new software to my server with Mercurial, it carefully deletes the old Python file and creates it in the new directory.
However, Mercurial is unaware of the pyc file in the same directory, and leaves it behind. The old pyc is used preferentially over new python file by other modules in the same directory.
What ensues is NOT hilarity.
How can I persuade Mercurial to automatically delete my old pyc file when I move the python file? Is there another better practice? Trying to remember to delete the pyc file from all the Mercurial repositories isn't working. | Automatically deleting pyc files when corresponding py is moved (Mercurial) | 1 | 0 | 0 | 7,805 |
2,531,479 | 2010-03-28T00:35:00.000 | 0 | 0 | 1 | 0 | python,ipython | 2,531,535 | 4 | false | 0 | 0 | The DeprecationWarning isn't emitted until the method is called, so you'd have to have a separate attribute on the class that stores the names of deprecated methods, then check that before suggesting a completion.
Alternatively, you could walk the AST for the method looking for DeprecationWarning, but that will fail if either the class is defined in C, or if the method may emit a DeprecationWarning based on the type or value of the arguments. | 1 | 3 | 0 | I would like to control which methods appear when a user uses tab-completion on a custom object in ipython - in particular, I want to hide functions that I have deprecated. I still want these methods to be callable, but I don't want users to see them and start using them if they are inspecting the object. Is this something that is possible? | Hide deprecated methods from tab completion | 0 | 0 | 0 | 991 |
2,531,717 | 2010-03-28T02:44:00.000 | 1 | 0 | 1 | 0 | python,django,keyword | 2,531,927 | 2 | false | 0 | 0 | Abbreviations like NO for navigation officer or OR for operations room need a little care lest you cause a SNAFU ;-) One suspects that better results could be obtained from "Find the NO and send her to the OR" by tagging the words with parts of speech using the context ... hint 1: "the OR" should result in "the [noun]" not "the [conjunction]". Hint 2: if in doubt about a word, keep it as a keyword. | 2 | 1 | 0 | I'm building a website in django that needs to extract key words from short (twitter-like) messages.
I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like "and", "or", "not" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any "simpler" packages out there that can do this?
EDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling. | Key word extraction in Python | 0.099668 | 0 | 0 | 1,322 |
2,531,717 | 2010-03-28T02:44:00.000 | 3 | 0 | 1 | 0 | python,django,keyword | 2,531,724 | 2 | true | 0 | 0 | You can make a set sw of the "stop words" you want to eliminate (maybe copy it once and for all from the stop words corpus of NLTK, depending how familiar you are with the various natural languages you need to support), then apply it very simply.
E.g., if you have a list of words sent that make up the sentence (shorn of punctuation and lowercased, for simplicity), [word for word in sent if word not in sw] is all you need to make a list of non-stopwords -- could hardly be easier, right?
To get the sent list in the first place, using the re module from the standard library, re.findall(r'\w+', sentstring) might suffice if sentstring is the string with the sentence you're dealing with -- it doesn't lowercase, but you can change the list comprehension I suggest above to [word for word in sent if word.lower() not in sw] to compensate for that and (btw) keep the word's original case, which may be useful. | 2 | 1 | 0 | I'm building a website in django that needs to extract key words from short (twitter-like) messages.
I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like "and", "or", "not" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any "simpler" packages out there that can do this?
EDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling. | Key word extraction in Python | 1.2 | 0 | 0 | 1,322 |
2,532,268 | 2010-03-28T08:05:00.000 | 0 | 0 | 0 | 0 | python,django,django-middleware,django-orm | 5,369,262 | 2 | false | 1 | 0 | You can set up one site for each "site", with it's own settings file, listening to it's own socket, using the same codebase. I'm doing that and I can easily support more than 30 concurrent sites on a middle-size server. Maintainability of configurations and startup scripts is the only issue. | 2 | 2 | 0 | I am creating multisites platform. Anybody can make simple site, with my platform. I plan to use django multidb support. One db for one site. And i need to change db settings depending on request.get_host().
I think that i's not good idea. Prompt other decisions? How it is realised on various designers of sites? | How to change db in django depending on request.get_host()? | 0 | 0 | 0 | 466 |
2,532,268 | 2010-03-28T08:05:00.000 | 1 | 0 | 0 | 0 | python,django,django-middleware,django-orm | 2,534,950 | 2 | false | 1 | 0 | You might want to reconsider using a separate db for reach site. In reviewing the multi-db source, it looks like you'll run into a few scalability issues, depending on how many sites you want to support:
Currently all the databases are set up in settings.py. This could cause a few issues:
Each new site would require reloading Django.
settings.py could get large.
A better approach might to use a single DB and associate the site/account with each record as needed. | 2 | 2 | 0 | I am creating multisites platform. Anybody can make simple site, with my platform. I plan to use django multidb support. One db for one site. And i need to change db settings depending on request.get_host().
I think that i's not good idea. Prompt other decisions? How it is realised on various designers of sites? | How to change db in django depending on request.get_host()? | 0.099668 | 0 | 0 | 466 |
2,532,840 | 2010-03-28T12:19:00.000 | 2 | 0 | 0 | 0 | python,django,content-management-system | 30,400,944 | 2 | false | 1 | 0 | I would say no. Django CMS is well designed, if you change content frequently. It has nice features to build up a page. But that means it only shows its benefits, when you create a lot pages/subpages and so on.
For a simple website that only presents data, without adding new pages/views, Django will suffice.
And from my experience, you should at lest be familiar with Views and URLs in order to use Django CMS well. But the same applies to Django itself. Everything else can be found on google.
Hope that helps. | 1 | 0 | 0 | I know python and have just read a basic intro of django. I have to built something like a travel website with real time updates. Will django be sufficent for this? Somebody advised me to look at django-CMS, I couldn't find a very beginner's tutorial there. Should I opt for django-CMS? Also how much of django should i know before i can try out django-cms?
Edit: Not too much real time stuff but just updates on the fly, like availibilty etc. Do i really need CMS?
Thanks | Using Django CMS | 0.197375 | 0 | 0 | 1,502 |
2,533,563 | 2010-03-28T16:18:00.000 | 8 | 0 | 1 | 0 | java,python,programming-languages | 26,374,367 | 7 | false | 0 | 0 | why its always 1st jan 1970 , Because - '1st January 1970' usually called as "epoch date" is the date when the time started for Unix computers, and that timestamp is marked as '0'. Any time since that date is calculated based on the number of seconds elapsed. In simpler words... the timestamp of any date will be difference in seconds between that date and '1st January 1970' The time stamp is just a integer which started from number '0' on 'Midnight 1st January 1970' and goes on incrementing by '1' as each second pass For conversion of UNIX timestamps to readable dates PHP and other open source languages provides built in functions. | 3 | 114 | 0 | Is there any reason behind using date(January 1st, 1970) as default standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Are there other popular languages which follows the same standard?
Please describe. | Why are dates calculated from January 1st, 1970? | 1 | 0 | 0 | 104,058 |
2,533,563 | 2010-03-28T16:18:00.000 | 1 | 0 | 1 | 0 | java,python,programming-languages | 2,533,568 | 7 | false | 0 | 0 | Yes, C (and its family). This is where Java took it too. | 3 | 114 | 0 | Is there any reason behind using date(January 1st, 1970) as default standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Are there other popular languages which follows the same standard?
Please describe. | Why are dates calculated from January 1st, 1970? | 0.028564 | 0 | 0 | 104,058 |
2,533,563 | 2010-03-28T16:18:00.000 | 3 | 0 | 1 | 0 | java,python,programming-languages | 16,132,913 | 7 | false | 0 | 0 | Q) "Why are dates calculated from January 1st, 1970?"
A) It had to be as recent as possible, yet include some past.
There was most likely no significant other reason as a lot of people feel that same way.
They knew it posed a problem if they placed it too far into the past and they knew it gave negative results if it was in the future. There was no need to go deeper in the past as events will most likely take place in the future.
Notes:
The mayans, on the other hand, had the need to place events into the past, since the had the knowledge of a lot of past, for which they made a long-term calender. Just to place all the routine phenomena on the calender.
The timestamp was not meant as a calender, it's an Epoch. And I believe the mayans made their long-term calender using that same perspective. (meaning they knew damn well they didn't have any relations with the past, they just had the need to see it in a bigger scale) | 3 | 114 | 0 | Is there any reason behind using date(January 1st, 1970) as default standard for time manipulation? I have seen this standard in Java as well as in Python. These two languages I am aware of. Are there other popular languages which follows the same standard?
Please describe. | Why are dates calculated from January 1st, 1970? | 0.085505 | 0 | 0 | 104,058 |
2,534,525 | 2010-03-28T20:55:00.000 | 1 | 1 | 0 | 0 | php,python,session,wsgi | 2,534,567 | 3 | false | 1 | 0 | Depends on the PHP app, if it's keeping session data in a database (MySQL maybe) you can just connect to the database and get the data, if it's using native PHP sessions you should look to the session.save_path config setting in php.ini, that's the place where the runtime saves files with the session data.
Once you have the data you can parse it to get it unserialized, take a look at how serialize() and unserialize() work in PHP. | 2 | 8 | 0 | I've got a python/WSGI app which needs to check to see if a user has logged on to a PHP web app. The problem is that the PHP app checks if a user has logged on by comparing a value in the $_SESSION variable to a value in the cookie from the user's browser. I would prefer to avoid changing the behavior of the php app if at all possible.
My questions:
Is there anyway I can access the session variables from within python? Where should I start to look?
Are there any obvious security/performance issues I should be aware of when taking this approach? | Accessing php $_SESSION from python (wsgi) - is it possible? | 0.066568 | 0 | 0 | 5,062 |
2,534,525 | 2010-03-28T20:55:00.000 | 4 | 1 | 0 | 0 | php,python,session,wsgi | 2,534,558 | 3 | false | 1 | 0 | yep. session (in default) is a regular file. so all what you need is look over session directory and find file with name of session cookie value. then - you have to implement php-like serialize/unserialize and do whatever you want.
nope | 2 | 8 | 0 | I've got a python/WSGI app which needs to check to see if a user has logged on to a PHP web app. The problem is that the PHP app checks if a user has logged on by comparing a value in the $_SESSION variable to a value in the cookie from the user's browser. I would prefer to avoid changing the behavior of the php app if at all possible.
My questions:
Is there anyway I can access the session variables from within python? Where should I start to look?
Are there any obvious security/performance issues I should be aware of when taking this approach? | Accessing php $_SESSION from python (wsgi) - is it possible? | 0.26052 | 0 | 0 | 5,062 |
2,534,527 | 2010-03-28T20:55:00.000 | -2 | 0 | 0 | 0 | python | 2,534,778 | 3 | false | 0 | 0 | File share and polling filesystem every minute. No joke. Of course, it depends on what are requirements for your applications and what lag is acceptable but in practice using file shares is quite common. | 2 | 3 | 0 | This whole topic is way out of my depth, so forgive my imprecise question, but I have two computers both connected to one LAN.
What I want is to be able to communicate one string between the two, by running a python script on the first (the host) where the string will originate, and a second on the client computer to retrieve the string.
What is the most efficient way for an inexperienced programmer like me to achieve this? | Python inter-computer communication | -0.132549 | 0 | 1 | 996 |
2,534,527 | 2010-03-28T20:55:00.000 | 4 | 0 | 0 | 0 | python | 2,534,582 | 3 | false | 0 | 0 | First, lets get the nomenclature straight. Usually the part that initiate the communication is the client, the parts that is waiting for a connection is a server, which then will receive the data from the client and generate a response. From your question, the "host" is the client and the "client" seems to be the server.
Then you have to decide how to transfer the data. You can use straight sockets, in which case you can use SocketServer, or you can rely on an existing protocol, like HTTP or XML-RPC, in which case you will find ready to use library packages with plenty of examples (e.g. xmlrpclib and SimpleXMLRPCServer) | 2 | 3 | 0 | This whole topic is way out of my depth, so forgive my imprecise question, but I have two computers both connected to one LAN.
What I want is to be able to communicate one string between the two, by running a python script on the first (the host) where the string will originate, and a second on the client computer to retrieve the string.
What is the most efficient way for an inexperienced programmer like me to achieve this? | Python inter-computer communication | 0.26052 | 0 | 1 | 996 |
2,534,943 | 2010-03-28T23:05:00.000 | 0 | 0 | 0 | 0 | python,django,synchronized | 24,900,469 | 4 | false | 1 | 0 | Great article Justin, just one thing using python 2.5 makes this way easier
In Python 2.5 and later, you can also use the with statement. When used with a lock, this statement automatically acquires the lock before entering the block, and releases it when leaving the block:
from future import with_statement # 2.5 only
with lock:
... access shared resource | 1 | 5 | 0 | Is there any way to block a critical area like with Java synchronized in Django? | Thread Synchronization in Django | 0 | 0 | 0 | 5,313 |
2,535,037 | 2010-03-28T23:35:00.000 | 4 | 0 | 1 | 0 | python,syntax | 2,535,050 | 5 | false | 0 | 0 | As far as I know, this isn't possible in 2.5. However, in 3.0, this was changed so that you can simply call super().__init__(). | 1 | 4 | 0 | I find this syntax astoundingly annoying. Every time I rename my class, I have to change this call for no apparent reason. Isn't there some __class__ magic variable or something I can use at least? Interested in answers for Python 2.5, but it doesn't hurt to know if later versions fixed this. | Way to call super(MyClass, self).__init__() without MyClass? | 0.158649 | 0 | 0 | 1,197 |
2,535,055 | 2010-03-28T23:40:00.000 | 1 | 1 | 0 | 0 | python,network-programming,network-protocols | 2,535,076 | 7 | false | 0 | 0 | Many firewalls are configured to drop ping packets without responding. In addition, some network adapters will respond to ICMP ping requests without input from the operating system network stack, which means the operating system might be down, but the host still responds to pings (usually you'll notice if you reboot the server, say, it'll start responding to pings some time before the OS actually comes up and other services start up).
The only way to be certain that a host is up is to actually try to connect to it via some well-known port (e.g. web server port 80).
Why do you need to know if the host is "up", maybe there's a better way to do it. | 3 | 10 | 0 | How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.
There is a possibility that the remote host might drop ping packets | Check if remote host is up in Python | 0.028564 | 0 | 1 | 46,690 |
2,535,055 | 2010-03-28T23:40:00.000 | 2 | 1 | 0 | 0 | python,network-programming,network-protocols | 2,535,139 | 7 | false | 0 | 0 | A protocol-level PING is best, i.e., connecting to the server and interacting with it in a way that doesn't do real work. That's because it is the only real way to be sure that the service is up. An ICMP ECHO (a.k.a. ping) would only tell you that the other end's network interface is up, and even then might be blocked; FWIW, I have seen machines where all user processes were bricked but which could still be pinged. In these days of application servers, even getting a network connection might not be enough; what if the hosted app is down or otherwise non-functional? As I said, talking sweet-nothings to the actual service that you are interested in is the best, surest approach. | 3 | 10 | 0 | How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.
There is a possibility that the remote host might drop ping packets | Check if remote host is up in Python | 0.057081 | 0 | 1 | 46,690 |
2,535,055 | 2010-03-28T23:40:00.000 | 1 | 1 | 0 | 0 | python,network-programming,network-protocols | 17,115,260 | 7 | false | 0 | 0 | What about trying something that requires a RPC like a 'tasklist' command in conjunction with a ping? | 3 | 10 | 0 | How would I check if the remote host is up without having a port number? Is there any other way I could check other then using regular ping.
There is a possibility that the remote host might drop ping packets | Check if remote host is up in Python | 0.028564 | 0 | 1 | 46,690 |
2,535,403 | 2010-03-29T01:54:00.000 | 3 | 0 | 1 | 0 | python,crash | 2,535,408 | 3 | false | 0 | 0 | You might try running your application directly from a console (cmd on windows, sh/bash/etc on unix), so you can see any stack trace, etc printed to the console when the process dies. | 1 | 8 | 0 | I have a python app which is supposed to be very long-lived, but sometimes the process just disappears and I don't know why. Nothing gets logged when this happens, so I'm at a bit of a loss.
Is there some way in code I can hook in to an exit event, or some other way to get some of my code to run just before the process quits? I'd like to log the state of memory structures to better understand what's going on. | Catching a python app before it exits | 0.197375 | 0 | 0 | 2,043 |
2,535,683 | 2010-03-29T03:38:00.000 | 3 | 0 | 1 | 0 | python,debugging,list,list-comprehension | 2,535,689 | 7 | true | 0 | 0 | If it's complicated enough that it's not obvious at first glance, unpack it into multiple steps and/or for loops. It's clearly too complicated, and making it more explicit is the easiest way to go about debugging it. Added bonus: you can now step through with the debugger or add print statements! | 3 | 19 | 0 | Python list comprehensions are nice, but near impossible to debug. You guys have any good tips / tools for debugging them? | Tips for debugging list comprehensions? | 1.2 | 0 | 0 | 4,854 |
2,535,683 | 2010-03-29T03:38:00.000 | 1 | 0 | 1 | 0 | python,debugging,list,list-comprehension | 2,535,701 | 7 | false | 0 | 0 | tip: Use list comprehension for simple tasks (1 or 2 levels). Otherwise, making it explicit is better for readability. | 3 | 19 | 0 | Python list comprehensions are nice, but near impossible to debug. You guys have any good tips / tools for debugging them? | Tips for debugging list comprehensions? | 0.028564 | 0 | 0 | 4,854 |
2,535,683 | 2010-03-29T03:38:00.000 | 0 | 0 | 1 | 0 | python,debugging,list,list-comprehension | 2,535,774 | 7 | false | 0 | 0 | Use a debugger like pdb to walk through or break the list comprehension into a full for loop. | 3 | 19 | 0 | Python list comprehensions are nice, but near impossible to debug. You guys have any good tips / tools for debugging them? | Tips for debugging list comprehensions? | 0 | 0 | 0 | 4,854 |
2,536,307 | 2010-03-29T07:14:00.000 | 18 | 0 | 1 | 0 | python,decorator,deprecated | 2,536,397 | 7 | false | 0 | 0 | I guess the reason is that Python code can't be processed statically (as it done for C++ compilers), you can't get warning about using some things before actually using it. I don't think that it's a good idea to spam user of your script with a bunch of messages "Warning: this developer of this script is using deprecated API".
Update: but you can create decorator which will transform original function into another. New function will mark/check switch telling that this function was called already and will show message only on turning switch into on state. And/or at exit it may print list of all deprecated functions used in program. | 1 | 186 | 0 | I need to mark routines as deprecated, but apparently there's no standard library decorator for deprecation. I am aware of recipes for it and the warnings module, but my question is: why is there no standard library decorator for this (common) task ?
Additional question: are there standard decorators in the standard library at all ? | decorators in the python standard lib (@deprecated specifically) | 1 | 0 | 0 | 110,084 |
2,536,468 | 2010-03-29T07:56:00.000 | 0 | 0 | 0 | 0 | python,debugging,pylons | 2,536,493 | 1 | true | 1 | 0 | (On the off-chance that this helps...)
Ubuntu's default Terminal program auto-detects URLs. When my pylons programs burp, I just ctrl-click on the link in the console. | 1 | 0 | 0 | Is there a way to view the latest debug message instead of having to copy and paste something like "_debug/view/1269848287" to the browser everytime? | Pylons: View latest debug message | 1.2 | 0 | 0 | 90 |
2,537,065 | 2010-03-29T10:02:00.000 | 5 | 0 | 0 | 1 | python,django,cgi,webserver,tornado | 3,244,176 | 2 | false | 1 | 0 | Main feature of Tornado is that it is high performance web-server written in Python, for creating web applications using Python programming language.
Running Tornado as CGI application negates the very reason it exists, because running CGI scripts is expensive in terms of performance, and most probably there is no way to run Tornado as CGI script. | 1 | 2 | 0 | Tornado is a webserver + framework like Django but for real-time features.
On my server I don't have a python module or wsgi module so I thought
CGI.
Is there a way to get Tornado ( or Django ) works by using CGI folder ?
If yes, Could you explain me how do I do that ? | Tornado or Django works with CGI? | 0.462117 | 0 | 0 | 1,611 |
2,539,109 | 2010-03-29T15:24:00.000 | 4 | 0 | 0 | 0 | python,django,authentication | 2,539,518 | 3 | false | 1 | 0 | Setting the session cookie age in the django session middleware just sets the expiry time in the set-cookie header passed back to the browser. It's only browser compliance with the expiry time that enforces the "log out".
Depending on your reasons for needing the idle log-out, you might not consider browser compliance with the expiry time good enough. In which case you'll need to extend the session middleware to do so.
For example you might store an expiry time in your session engine which you update with requests. Depending on the nature of traffic to your site, you may wish to only write back to the session object once in X seconds to avoid excessive db writes. | 1 | 28 | 0 | I'm working on a website that requires us to log a user out after N minutes of inactivity. Are there any best practices for this using Django? | Logging users out of a Django site after N minutes of inactivity | 0.26052 | 0 | 0 | 17,914 |
2,539,147 | 2010-03-29T15:30:00.000 | 3 | 0 | 1 | 0 | python,sql,orm | 2,539,235 | 4 | false | 0 | 0 | SQLAlchemy offers an ORM much like django, but does not require that you work within a web framework. | 1 | 1 | 0 | I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that:
Creates a database table from a simple type description (int, float, datetime etc)
Takes a dictionary object and inserts it into the database (including handling datetime objects!)
If possible: Can handle basic references, so the dictionary can reference other tables
I would prefer something that doesn't do a lot of magic. I just need an easy way to setup and get data into an SQL database.
What would you suggest? There seems to be a lot of ORM software around, but I find it hard to evaluate them. | Lightweight Object->Database in Python | 0.148885 | 1 | 0 | 1,069 |
2,540,460 | 2010-03-29T18:54:00.000 | 0 | 0 | 0 | 1 | python,unix | 2,540,756 | 5 | false | 0 | 0 | I would parse /etc/passwd for the username in question. Users may not necessarily have homedir's. | 1 | 21 | 0 | What is the easiest way to check the existence of a user on a GNU/Linux OS, using Python?
Anything better than issuing ls ~login-name and checking the exit code?
And if running under Windows? | How to check if a user exists in a GNU/Linux OS using Python? | 0 | 0 | 0 | 15,746 |
2,541,254 | 2010-03-29T21:01:00.000 | 1 | 0 | 0 | 0 | python,netbeans,import,module,pygame | 2,908,642 | 1 | false | 0 | 1 | Well I've just finished installing it on my Mac - you have to watch out for the Python Platform under Tools and File. The default is Jython, but you want to change it to point to your python version in the Frameworks file of your Library.
Does that make sense? | 1 | 0 | 0 | I am running python 2.6.5 and pygame 1.9.1 It seems to me I've tried everything but it keeps showing 'module not found' errors... Please help! | Can't import pygame to Netbeans on Mac | 0.197375 | 0 | 0 | 997 |
2,541,702 | 2010-03-29T22:34:00.000 | 3 | 0 | 0 | 0 | python,lotus-notes,lotus | 2,542,163 | 3 | false | 1 | 0 | The short answer is, unfortunately you will need the Notes client installed. There are a few ways to access data from an NSF such as NotesSQL, COM, C/C++, but all rely on the Lotus C API at the core, and you'll need a notes client and a notes ID file to gain access via that API. | 3 | 0 | 0 | I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.
Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL
From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.
The problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.
Any ideas on how best to do this welcome :) | Access to content of Lotus Notes database without Lotus Notes software installed | 0.197375 | 0 | 0 | 3,704 |
2,541,702 | 2010-03-29T22:34:00.000 | 0 | 0 | 0 | 0 | python,lotus-notes,lotus | 2,551,002 | 3 | false | 1 | 0 | Like Ken says, inevitably there has to be a server in the mix. If you're searching for specific text in a Notes / Domino application, and looking to replace it, there's a tool out there which does this: Teamstudio Configurator.
Configurator also has an API (written in Lotusscript, which is very like old-skool VB) so you can code a solution pretty quickly. I've done the exact same thing you're doing with an old Domino-based website, using this API.
Not the answer you're looking for I guess, but always good to have choices! | 3 | 0 | 0 | I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.
Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL
From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.
The problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.
Any ideas on how best to do this welcome :) | Access to content of Lotus Notes database without Lotus Notes software installed | 0 | 0 | 0 | 3,704 |
2,541,702 | 2010-03-29T22:34:00.000 | 1 | 0 | 0 | 0 | python,lotus-notes,lotus | 2,607,921 | 3 | false | 1 | 0 | If this is a one-time need, you may be able to find sites that will do some simple Domino/Notes hosting for free. If you could put the NSF up to a service like that, you could then use Domino URL's (REST) to extract the data and search for links, etc. | 3 | 0 | 0 | I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed.
Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL
From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed.
The problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site.
Any ideas on how best to do this welcome :) | Access to content of Lotus Notes database without Lotus Notes software installed | 0.066568 | 0 | 0 | 3,704 |
2,541,742 | 2010-03-29T22:42:00.000 | 4 | 0 | 0 | 0 | python,cookies,session,security | 2,542,128 | 8 | true | 1 | 0 | If the only information in the cookie is an identifier, essentially a label, the only attack you're trying to protect from is an attacker guessing what it is. So use some random bytes. Enough random bytes that it's "unguessable."
Then squish the random bytes into something that fits within the confines of which characters you can use in a HTTP cookie. base64 works for this. It's not absolutely optimal, because there are more than 64 cookie-safe characters and it tends to leave trailing == characters which add bytes to the header but not randomness, but that's fine. It works and Python can probably do the base64 encoding faster than anything else we can come up with.
If you also want to prepend the user ID to it, that will make things easier to trace and debug, which will probably make your life easier, so go ahead. It doesn't give an attacker any significant advantage. (unless they manage to steal one without being able to otherwise determine what user they're stealing from, which seems unlikely.) | 2 | 6 | 0 | I'm writing my own sessions controller that issues a unique id to a user once logged in, and then verifies and authenticates that unique id at every page load. What is the most secure way to generate such an id? Should the unique id be completely random? Is there any downside to including the user id as part of the unique id? | Most secure way to generate a random session ID for a cookie? | 1.2 | 0 | 0 | 13,882 |
2,541,742 | 2010-03-29T22:42:00.000 | 0 | 0 | 0 | 0 | python,cookies,session,security | 29,989,100 | 8 | false | 1 | 0 | I would avoid the random factor completely. What I've generally done is:
Generate a sequential session_id (which I store locally).
When the user logs in, sign session_id with a private key (I use itsdangerous for this).
When I get a request, if the session_id's signature is intact, I proceed, otherwise, 403 (400 would make sense too).
Note that I store the session_id locally because I want to be able to expire end sessions prematurely.
If your sessions always last a fixed amount of time, and you don't need to end them prematurely, you can simply sign user_id + datetime.now(). This allows completely stateless session management. | 2 | 6 | 0 | I'm writing my own sessions controller that issues a unique id to a user once logged in, and then verifies and authenticates that unique id at every page load. What is the most secure way to generate such an id? Should the unique id be completely random? Is there any downside to including the user id as part of the unique id? | Most secure way to generate a random session ID for a cookie? | 0 | 0 | 0 | 13,882 |
2,542,025 | 2010-03-29T19:33:00.000 | 1 | 0 | 0 | 1 | python,network-shares | 2,542,026 | 1 | true | 0 | 0 | Mount the shares using Samba, check the free space on the share using df or os.statvfs and read/write to it like any other folder. | 1 | 1 | 0 | How to Write/Read a file to/from a network folder/share using python? The application will run under Linux and network folder/share can be a Linux/Windows System.
Also, how to check that network folder/share has enough space before writing a file?
What things should i consider? | Read/Write a file from/to network folder/share using Python? | 1.2 | 0 | 1 | 1,813 |
2,542,206 | 2010-03-30T00:47:00.000 | 2 | 0 | 0 | 0 | python,timezone,pylons | 2,542,216 | 1 | true | 0 | 0 | You can't get the client's timezone using server-side code, you can, however:
use Javascript: Date.getTimezoneOffset();
use geolocation to determine where the user is located and deduce the timezone from the location | 1 | 2 | 0 | Is there a way to get the timezone of the connecting user using Pylons, and to adjust the content before rendering accordingly? Or can this only be done by JS?
Thanks. | Get a user's timezone in Python + Pylons | 1.2 | 0 | 0 | 590 |
2,542,674 | 2010-03-30T03:20:00.000 | 5 | 0 | 0 | 0 | python,django | 2,542,702 | 5 | false | 1 | 0 | The python interpreter does not look everywhere on your path to find the script. It does look everywhere for imports, but not for scripts.
Try typing django-admin.py, just django-admin.py and not python django-admin.py, and it should work. Windows should find it on the path, then execute it as a python script.
OK,
If Windows doesn't run Python scripts (i.e. you have set your editor as the default python app), try: python -m django-admin or maybe python -m django-admin.py. The -m argument uses module mode, which checks the path. | 4 | 3 | 0 | I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any suggestions? | No matter what I do, django-admin.py is not found, even though it's in my path | 0.197375 | 0 | 0 | 6,085 |
2,542,674 | 2010-03-30T03:20:00.000 | 4 | 0 | 0 | 0 | python,django | 2,543,312 | 5 | false | 1 | 0 | python -mdjango-admin looks like what you're looking for. -m tells Python to find a module on sys.path and run that module as "the main script" -- which seems exactly your goal! | 4 | 3 | 0 | I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any suggestions? | No matter what I do, django-admin.py is not found, even though it's in my path | 0.158649 | 0 | 0 | 6,085 |
2,542,674 | 2010-03-30T03:20:00.000 | 5 | 0 | 0 | 0 | python,django | 14,559,937 | 5 | false | 1 | 0 | I realize this is old, but came across the same issue.
On Windows, your path should include the following:
C:\Python27\;C:\Python27\Scripts
This is assuming python 2.7.3 is installed and django 1.4.3 | 4 | 3 | 0 | I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any suggestions? | No matter what I do, django-admin.py is not found, even though it's in my path | 0.197375 | 0 | 0 | 6,085 |
2,542,674 | 2010-03-30T03:20:00.000 | 0 | 0 | 0 | 0 | python,django | 2,718,527 | 5 | false | 1 | 0 | I had the same problem, and python -mdjango-admin works. but i had to define PYTHONHOME & PYTHONPATH first | 4 | 3 | 0 | I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any suggestions? | No matter what I do, django-admin.py is not found, even though it's in my path | 0 | 0 | 0 | 6,085 |
2,542,809 | 2010-03-30T04:02:00.000 | 3 | 0 | 1 | 0 | python,import | 2,542,833 | 4 | false | 0 | 0 | I figured it out. Imported modules have a __file__ field that is the file that was loaded. Combine that with __import__, I defined a function:
which = lambda str : __import__(str).__file__. | 2 | 7 | 0 | How do you determine which file is imported in Python with an "import" statement?
I want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment. | How do you determine which file is imported in Python with an "import" statement? | 0.148885 | 0 | 0 | 2,953 |
2,542,809 | 2010-03-30T04:02:00.000 | 10 | 0 | 1 | 0 | python,import | 2,542,840 | 4 | false | 0 | 0 | Look at its __file__ attribute. | 2 | 7 | 0 | How do you determine which file is imported in Python with an "import" statement?
I want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment. | How do you determine which file is imported in Python with an "import" statement? | 1 | 0 | 0 | 2,953 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.