Q_Id int64 337 49.3M | CreationDate stringlengths 23 23 | Users Score int64 -42 1.15k | Other int64 0 1 | Python Basics and Environment int64 0 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 105 | A_Id int64 518 72.5M | AnswerCount int64 1 64 | is_accepted bool 2
classes | Web Development int64 0 1 | GUI and Desktop Applications int64 0 1 | Answer stringlengths 6 11.6k | Available Count int64 1 31 | Q_Score int64 0 6.79k | Data Science and Machine Learning int64 0 1 | Question stringlengths 15 29k | Title stringlengths 11 150 | Score float64 -1 1.2 | Database and SQL int64 0 1 | Networking and APIs int64 0 1 | ViewCount int64 8 6.81M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,556,305 | 2010-08-24T12:18:00.000 | 10 | 0 | 0 | 0 | python,mysql,mysql-python | 3,556,313 | 4 | true | 0 | 0 | SHOW tables
15 chars | 1 | 35 | 0 | I have an SQL database and am wondering what command you use to just get a list of the table names within that database. | How to retrieve table names in a mysql database with Python and MySQLdb? | 1.2 | 1 | 0 | 62,222 |
3,557,830 | 2010-08-24T14:59:00.000 | -3 | 0 | 1 | 1 | encoding,python-3.x,filenames,command-line-arguments | 3,559,991 | 2 | false | 0 | 0 | Don't go against the grain: filenames are strings, not bytes.
You shouldn't use a bytes when you should use a string. A bytes is a tuple of integers. A string is a tuple of characters. They are different concepts. What you're doing is like using an integer when you should use a boolean.
(Aside: Python stores all strings in-memory under Unicode; all strings are stored the same way. Encoding specifies how Python converts the on-file bytes into this in-memory format.)
Your operating system stores filenames as strings under a specific encoding. I'm surprised you say that some filenames have different encodings; as far as I know, the filename encoding is system-wide. Functions like open default to the default system filename encoding, for example. | 1 | 4 | 0 | I'm writing a python3 program, that gets the names of files to process from command-line arguments. I'm confused regarding what is the proper way to handle different encodings.
I think I'd rather consider filenames as bytes and not strings, since that avoids the danger of using an incorrect encoding. Indeed, some of my file names use an incorrect encoding (latin1 when my system locale uses utf-8), but that doesn't prevent tools like ls from working. I'd like my tool to be resilient to that as well.
I have two problems: the command-line arguments are given to me as strings (I use argparse), and I want to report errors to the user as strings.
I've successfuly adapted my code to use binaries, and my tool can handle files whose name are invalid in the current default encoding, as long as it is by recursing trough the filesystem, because I convert the arguments to binaries early, and use binaries when calling fs functions. When I receive a filename argument which is invalid, however, it is handed to me as a unicode string with strange characters like \udce8. I do not know what these are, and trying to encode it always fail, be it with utf8 or with the corresponding (wrong) encoding (latin1 here).
The other problem is for reporting errors. I expect users of my tool to parse my stdout (hence wanting to preserve filenames), but when reporting errors on stderr I'd rather encode it in utf-8, replacing invalid sequences with appropriate "invalid/question mark" characters.
So,
1) Is there a better, completely different way to do it ? (yes, fixing the filenames is planned, but i'd still like my tool to be robust)
2) How do I get the command line arguments in their original binary form (not pre-decoded for me), knowing that for invalid sequences re-encoding the decoded argument will fail, and
3) How do I tell the utf-8 codec to replace invalid, undecodable sequences with some invalid mark rather than dying on me ? | Command-line arguments as bytes instead of strings in python3 | -0.291313 | 0 | 0 | 2,162 |
3,557,949 | 2010-08-24T15:11:00.000 | 0 | 0 | 1 | 1 | python,python-install | 3,558,004 | 2 | false | 0 | 0 | There has to be a way, but what some people do is provide batch files that set up the environment before invoking Python. That's what BZR does, anyway. If you can write that batch file somewhere that's already normally in the path, so much the better.
If you're just worried about invoking Python, the normal Python installer does file associations, so you can work it that way. | 1 | 1 | 0 | I'm creating one-click python installer (integrated with my application). Is there any way to force Python MSI installer to add python's path to SYSTEM PATH variable?
I'm using MSI installer because it is very easy to specify (using command line) how it should interact with the user. | add Python path to PATH system variable automatically under Windows | 0 | 0 | 0 | 1,668 |
3,558,907 | 2010-08-24T16:54:00.000 | 3 | 0 | 0 | 0 | python,django,django-models,foreign-keys | 3,829,427 | 6 | false | 1 | 0 | This is probably as simple as declaring a ForeignKey and creating the column without actually declaring it as a FOREIGN KEY. That way, you'll get o.obj_id, o.obj will work if the object exists, and--I think--raise an exception if you try to load an object that doesn't actually exist (probably DoesNotExist).
However, I don't think there's any way to make syncdb do this for you. I found syncdb to be limiting to the point of being useless, so I bypass it entirely and create the schema with my own code. You can use syncdb to create the database, then alter the table directly, eg. ALTER TABLE tablename DROP CONSTRAINT fk_constraint_name.
You also inherently lose ON DELETE CASCADE and all referential integrity checking, of course. | 2 | 12 | 0 | I'd like to set up a ForeignKey field in a django model which points to another table some of the time. But I want it to be okay to insert an id into this field which refers to an entry in the other table which might not be there. So if the row exists in the other table, I'd like to get all the benefits of the ForeignKey relationship. But if not, I'd like this treated as just a number.
Is this possible? Is this what Generic relations are for? | Django ForeignKey which does not require referential integrity? | 0.099668 | 0 | 0 | 7,485 |
3,558,907 | 2010-08-24T16:54:00.000 | -2 | 0 | 0 | 0 | python,django,django-models,foreign-keys | 62,528,120 | 6 | false | 1 | 0 | tablename= columnname.ForeignKey('table', null=True, blank=True, db_constraint=False)
use this in your program | 2 | 12 | 0 | I'd like to set up a ForeignKey field in a django model which points to another table some of the time. But I want it to be okay to insert an id into this field which refers to an entry in the other table which might not be there. So if the row exists in the other table, I'd like to get all the benefits of the ForeignKey relationship. But if not, I'd like this treated as just a number.
Is this possible? Is this what Generic relations are for? | Django ForeignKey which does not require referential integrity? | -0.066568 | 0 | 0 | 7,485 |
3,559,457 | 2010-08-24T17:55:00.000 | 1 | 1 | 1 | 0 | python,multithreading,tornado,gil | 3,562,109 | 1 | false | 0 | 0 | The first thing I would check for would be to ensure that you're properly exiting threads. It's very hard to figure out what's going on with just your description to go from, but you use the word "monotonically," which implies that CPU use is tied to time rather than to load.
You may very well be running into threading limits of Python, but it should vary up and down with load (number of active threads,) and CPU usage (context switching costs) should reduce as those threads exit. Is there some reason for a thread, once created, to live forever? If that's the case, prioritize that rearchitecture. Otherwise, short term would be to figure out why CPU usage is tied to time and not load. It implies that each new thread has a permanent, irreversible cost in your system - meaning it never exits. | 1 | 8 | 0 | I'm just starting to work on a tornado application that is having some CPU issues. The CPU time will monotonically grow as time goes by, maxing out the CPU at 100%. The system is currently designed to not block the main thread. If it needs to do something that blocks and asynchronous drivers aren't available, it will spawn another thread to do the blocking operation.
Thus we have the main thread being almost totally CPU-bound and a bunch of other threads that are almost totally IO-bound. From what I've read, this seems to be the perfect way to run into problems with the GIL. Plus, my profiling shows that we're spending a lot of time waiting on signals (which I'm assuming is what __semwait_signal is doing), which is consistent with the effects the GIL would have in my limited understanding.
If I use sys.setcheckinterval to set the check interval to 300, the CPU growth slows down significantly. What I'm trying to determine is whether I should increase the check interval, leave it at 300, or be scared with upping it. After all, I notice that CPU performance gets better, but I'm a bit concerned that this will negatively impact the system's responsiveness.
Of course, the correct answer is probably that we need to rethink our architecture to take the GIL into account. But that isn't something that can be done immediately. So how do I determine the appropriate course of action to take in the short-term? | How do I determine the appropriate check interval? | 0.197375 | 0 | 0 | 765 |
3,559,559 | 2010-08-24T18:06:00.000 | -8 | 0 | 1 | 0 | python,string | 3,559,604 | 17 | false | 0 | 0 | Strings are immutable in Python so both your options mean the same thing basically. | 1 | 542 | 0 | There is a string, for example. EXAMPLE.
How can I remove the middle character, i.e., M from it? I don't need the code. I want to know:
Do strings in Python end in any special character?
Which is a better way - shifting everything right to left starting from the middle character OR creation of a new string and not copying the middle character? | How to delete a character from a string using Python | -1 | 0 | 0 | 1,850,874 |
3,560,246 | 2010-08-24T19:25:00.000 | 1 | 1 | 1 | 0 | python,web-hosting,python-imaging-library | 3,560,296 | 2 | false | 0 | 0 | You need to compile that module. Running the setup.py install command should do it for you, provided the host has a working compiler and the required libraries. You can use virtualenv to have it installed somewhere where you have rights to put files (by default it would try to install it system-wide).
If it doesn't have a working compiler and right libraries and header files, then you need to either compile it on another computer with the same architecture and copy it, or find the packages for whatever operating system your host is running and extract the right files from them.
By the way, just asking them to install PIL could work too! | 1 | 0 | 0 | I want to be able to use the PIL library on a web hosting machine. The machine has Python 2.4.3 installed, but not the PIL library. I tried downloading the PIL source and putting the PIL folder into my directory. It kind of works, except when I need to do some actual image processing, which brings up an ImportError, saying that "The _imaging C module is not installed". Googling this, it seems like I would need to throw an _imaging.so file into the PIL folder, but I couldn't find a precompiled one online.
At this point, I'm not sure if I'm even on the right track. What should I do from here? Any help is appreciated.
Thanks. | Using PIL on web hosting machine | 0.099668 | 0 | 0 | 192 |
3,561,209 | 2010-08-24T21:32:00.000 | 0 | 0 | 1 | 1 | python,macos,dylib | 3,561,953 | 2 | false | 0 | 0 | Run the included setup.py file. You should never try to copy things into place manually; it'll lead to disaster, especially in situations involving pip or easy_install. | 2 | 0 | 0 | On Mac OSX 10.6.4 where do you install dynamic libraries (dylib) so Python 2.6.1 can import them? I've tried placing them in /usr/local/lib and usr/localbin and /Library/Python/2.6/site-packages but none of these locations have worked. The library I'm trying to install is libevecache.dylib a library to access cache files for Eve-Online. | Where are Python dylibs installed on the Mac? | 0 | 0 | 0 | 2,538 |
3,561,209 | 2010-08-24T21:32:00.000 | 0 | 0 | 1 | 1 | python,macos,dylib | 3,561,232 | 2 | false | 0 | 0 | Anywhere in your $DYLD_LIBRARY_PATH should work for compiled library files; you can also try setting $PYTHONPATH / sys.path. | 2 | 0 | 0 | On Mac OSX 10.6.4 where do you install dynamic libraries (dylib) so Python 2.6.1 can import them? I've tried placing them in /usr/local/lib and usr/localbin and /Library/Python/2.6/site-packages but none of these locations have worked. The library I'm trying to install is libevecache.dylib a library to access cache files for Eve-Online. | Where are Python dylibs installed on the Mac? | 0 | 0 | 0 | 2,538 |
3,561,691 | 2010-08-24T23:04:00.000 | 115 | 0 | 1 | 0 | python,string,string-literals | 5,141,611 | 17 | false | 0 | 0 | I had this problem - I eventually worked out that the reason was that I'd included \ characters in the string. If you have any of these, "escape" them with \\ and it should work fine. | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 1 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 3 | 0 | 1 | 0 | python,string,string-literals | 65,559,216 | 17 | false | 0 | 0 | In my case, I forgot (' or ") at the end of string. E.g 'ABC' or "ABC" | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 0.035279 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 4 | 0 | 1 | 0 | python,string,string-literals | 18,255,999 | 17 | false | 0 | 0 | I also had this exact error message, for me the problem was fixed by adding an " \"
It turns out that my long string, broken into about eight lines with " \" at the very end, was missing a " \" on one line.
Python IDLE didn't specify a line number that this error was on, but it red-highlighted a totally correct variable assignment statement, throwing me off. The actual misshapen string statement (multiple lines long with " \") was adjacent to the statement being highlighted. Maybe this will help someone else. | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 0.047024 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 3 | 0 | 1 | 0 | python,string,string-literals | 48,500,882 | 17 | false | 0 | 0 | I was getting this error in postgresql function. I had a long SQL which I broke into multiple lines with \ for better readability. However, that was the problem. I removed all and made them in one line to fix the issue. I was using pgadmin III. | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 0.035279 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 0 | 0 | 1 | 0 | python,string,string-literals | 59,079,686 | 17 | false | 0 | 0 | Most previous answers are correct and my answer is very similar to aaronasterling, you could also do 3 single quotations
s1='''some very long string............''' | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 0 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 8 | 0 | 1 | 0 | python,string,string-literals | 34,544,032 | 17 | false | 0 | 0 | I faced a similar problem. I had a string which contained path to a folder in Windows e.g. C:\Users\ The problem is that \ is an escape character and so in order to use it in strings you need to add one more \.
Incorrect: C:\Users\
Correct: C:\\\Users\\\ | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 1 | 0 | 0 | 1,101,899 |
3,561,691 | 2010-08-24T23:04:00.000 | 5 | 0 | 1 | 0 | python,string,string-literals | 18,286,044 | 17 | false | 0 | 0 | I too had this problem, though there were answers here I want to an important point to this
after
/ there should not be empty spaces.Be Aware of it | 7 | 204 | 0 | I have the above-mentioned error in s1="some very long string............"
Does anyone know what I am doing wrong? | python: SyntaxError: EOL while scanning string literal | 0.058756 | 0 | 0 | 1,101,899 |
3,561,993 | 2010-08-25T00:18:00.000 | 0 | 0 | 0 | 0 | c#,java,python,gmail,selenium-rc | 3,562,629 | 2 | false | 0 | 0 | If you want to emulate a click on the button, just go to #compose. | 1 | 1 | 0 | I have tried this probably 6 or 7 different ways, such as using various attribute values, XPath, id pattern matching (it always matches ":\w\w"), etc. as locators, and nothing has worked. If anyone can give me a tested, confirmed-working locator string for this button, I'd be much obliged. | How to access Gmail's "Send" button using Selenium RC for Java or C# or Python | 0 | 0 | 1 | 964 |
3,562,406 | 2010-08-25T02:15:00.000 | 1 | 0 | 0 | 0 | mysql,python-2.7 | 58,359,370 | 3 | false | 1 | 0 | For Python 2.7 on specific programs:
sudo chown -R $USER /Library/Python/2.7
brew install mysql@5.7
brew install mysql-connector-c
brew link --overwrite mysql@5.7
echo 'export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"' >> ~/.bash_profile
sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config
pip install MySql-python
This solved all issues I was having running a program that ran on Python 2.7 on and older version of MySql | 1 | 1 | 0 | While I see a bunch of links/binaries for mysql connector for python 2.6, I don't see one for 2.7
To use django, should I just revert to 2.6 or is there a way out ?
I'm using windows 7 64bit
django - 1.1
Mysql 5.1.50
Any pointers would be great. | Is there no mysql connector for python 2.7 on windows | 0.066568 | 1 | 0 | 2,224 |
3,562,466 | 2010-08-25T02:32:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine | 3,562,948 | 2 | true | 1 | 0 | Attempt to perform a query that requires that index. If it raises a NeedIndexError, it's not uploaded or not yet serving. | 1 | 1 | 0 | How can I check if datastore Indexes as defined in index.yaml are serving in the python code?
I am using Python 1.3.6 AppEngine SDK. | How to check if DataStore Indexes are being served on AppEngine? | 1.2 | 0 | 0 | 244 |
3,562,643 | 2010-08-25T03:19:00.000 | 3 | 1 | 0 | 0 | python,hudson,code-coverage,coverage.py,python-coverage | 3,562,678 | 2 | true | 0 | 0 | Currently, coverage.py doesn't know how to find files that are never executed and report them as not covered, but that will be coming in the next release. So now, the file coverage will always be 100%. This is an area where Hudson (using the Cobertura plugin) and coverage.py don't mesh very well. | 1 | 5 | 0 | We are using Hudson and coverage.py to report the code coverage of our test suite. Hudson breaks down coverage into:
packages
files
classes
lines
conditionals
Coverage.py only reports coverage on files executed/imported during the tests, and so it seems is oblivious to any files not executed during the tests. Is there ever an instance where files would not report 100% coverage? | When would my Python test suite file coverage not be 100%? | 1.2 | 0 | 0 | 517 |
3,563,126 | 2010-08-25T05:42:00.000 | 2 | 0 | 0 | 0 | python,url-encoding | 3,563,366 | 3 | false | 1 | 0 | You are out of your luck with stdlib, urllib.quote doesn't work with unicode. If you are using django you can use django.utils.http.urlquote which works properly with unicode | 1 | 48 | 0 | I am trying to encode and store, and decode arguments in Python and getting lost somewhere along the way. Here are my steps:
1) I use google toolkit's gtm_stringByEscapingForURLArgument to convert an NSString properly for passing into HTTP arguments.
2) On my server (python), I store these string arguments as something like u'1234567890-/:;()$&@".,?!\'[]{}#%^*+=_\\|~<>\u20ac\xa3\xa5\u2022.,?!\'' (note that these are the standard keys on an iphone keypad in the "123" view and the "#+=" view, the \u and \x chars in there being some monetary prefixes like pound, yen, etc)
3) I call urllib.quote(myString,'') on that stored value, presumably to %-escape them for transport to the client so the client can unpercent escape them.
The result is that I am getting an exception when I try to log the result of % escaping. Is there some crucial step I am overlooking that needs to be applied to the stored value with the \u and \x format in order to properly convert it for sending over http?
Update: The suggestion marked as the answer below worked for me. I am providing some updates to address the comments below to be complete, though.
The exception I received cited an issue with \u20ac. I don't know if it was a problem with that specifically, rather than the fact that it was the first unicode character in the string.
That \u20ac char is the unicode for the 'euro' symbol. I basically found I'd have issues with it unless I used the urllib2 quote method. | URL encoding/decoding with Python | 0.132549 | 0 | 1 | 83,104 |
3,564,177 | 2010-08-25T08:47:00.000 | 1 | 0 | 0 | 1 | python,scala,groovy,shell,jython | 3,564,251 | 6 | false | 0 | 0 | Although I prefer working on the JVM, one thing that turns me off is having to spin up a JVM to run a script. If you can work in a REPL this is not such a big deal, but it really slows you down when doing edit-run-debug scripting.
Now of course Oracle has a lot of Java stuff where interaction moght be needed, but that is something only you can estimate how important it is. For plain Oracle DB work I have seen very little Java and lots fo PLSQL/SQL.
If your dba now do their work in bash, then they will very likely pickup perl in a short time as there is a nice, logical progression path.
Since ruby was designed to be an improved version of perl, it might fit in that category too. Actually python also.
Scala is statically typed like Java, albeit with much better type inference.
My recommendation would be to go the Perl route. The CPAN is its ace in the hole, you do not have to deal with the OO stuff which might turn off some DBA's (although it is there for the power users). | 5 | 6 | 0 | I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and support customers on Windows, Solaris and Linux servers.
Many of the tasks we do on a frequent basis are insufficiently automated, and where they are, tend to be much more automated via shell scripts, with little equivalent functionality on Windows. Unfortunately, we now have this problem of redeveloping scripts and so on, on two platforms. So, I wish for us to choose a cross platform language to script in, instead of using Bash and awkwardly translating to Cygwin or Batch files where necessary.
It would need to be:
Dynamic (so don't suggest Java or C!)
Easily available on each platform (Windows, Solaris, Linux, perhaps AIX)
Require very little in the way of setup (root access not always available!)
Be easy for shell scripters, i.e. DBAs, to adopt, who are not hardcore developers.
Be easy to understand other people's code
Friendly with SQL Server and Oracle, without messing around.
A few nice XML features wouldn't go amiss.
It would be preferable if it would run on the JVM, since this will almost always be installed on every server (certainly on all application servers) and we have many Java developers in our company, so sticking to the JVM makes sense. This isn't exclusive though, since I know Python is a very viable language here.
I have created a list of options, but there may be more: Groovy, Scala, Jython, Python, Ruby, Perl.
No one has much experience of any, except I have quite a lot of Java and Groovy experience myself. We are looking for something dynamic, easy to pick up, will work with both SQL server and Oracle effortlessly, has some XML simplifying features, and that won't be a turnoff for DBAs. Many of us are very Bash orientated - what could move us away from this addiction?
What are people's opinions on this?
thanks!
Chris | Which cross platform scripting language should we adopt for a group of DBAs? | 0.033321 | 1 | 0 | 3,213 |
3,564,177 | 2010-08-25T08:47:00.000 | 0 | 0 | 0 | 1 | python,scala,groovy,shell,jython | 3,564,285 | 6 | false | 0 | 0 | I've been in a similar situation, though on a small scale. The previous situation was that any automation on the SQL Server DBs was done with VBScript, which I did start out using. As I wanted something cross-platform (and less annoying than VBScript) I went with Python.
What I learnt is:
Obviously you want a language that comes with libraries to access your databases comfortably. I wasn't too concerned with abstracting the differences away (ie, I still wrote SQL queries in the relevant dialect, with parameters). However, I'd be a bit less happy with PHP, for example, which has only very vendor-specific libraries and functions for certain databases. I see it's not on your list.
THE major obstacle was authentication. If your SQL Server uses Windows domain authentication, you'll have to work to get in. Another system also had specific needs as it required RSA tokens to be supported.
For the second point, Python is quite versatile enough to work around the difficulties, but it was getting into "badly supported" territory, especially on Windows. It was easy to work around the first problem from a Windows host, and for a Unix host it is possible though not easy. If you're using SQL Server authentication, it becomes a lot easier.
From your other choices, I'd expect various ways of authenticating and DB drivers to exist for Perl, which philosophically would be easier for DBAs used to shell scripting. Ruby - no experience, but it tends to have spotty support for some of the odder authentication methods and connectors. Scala I'd expect to be a bit too much of a "programmer's programming language" -- OOO and FP? It's a very interesting language, but maybe not the one I'd chose at first. As for the rest of the Java-based options, I don't have an opinion, but do check that all the connection types you want to make are solidly supported. | 5 | 6 | 0 | I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and support customers on Windows, Solaris and Linux servers.
Many of the tasks we do on a frequent basis are insufficiently automated, and where they are, tend to be much more automated via shell scripts, with little equivalent functionality on Windows. Unfortunately, we now have this problem of redeveloping scripts and so on, on two platforms. So, I wish for us to choose a cross platform language to script in, instead of using Bash and awkwardly translating to Cygwin or Batch files where necessary.
It would need to be:
Dynamic (so don't suggest Java or C!)
Easily available on each platform (Windows, Solaris, Linux, perhaps AIX)
Require very little in the way of setup (root access not always available!)
Be easy for shell scripters, i.e. DBAs, to adopt, who are not hardcore developers.
Be easy to understand other people's code
Friendly with SQL Server and Oracle, without messing around.
A few nice XML features wouldn't go amiss.
It would be preferable if it would run on the JVM, since this will almost always be installed on every server (certainly on all application servers) and we have many Java developers in our company, so sticking to the JVM makes sense. This isn't exclusive though, since I know Python is a very viable language here.
I have created a list of options, but there may be more: Groovy, Scala, Jython, Python, Ruby, Perl.
No one has much experience of any, except I have quite a lot of Java and Groovy experience myself. We are looking for something dynamic, easy to pick up, will work with both SQL server and Oracle effortlessly, has some XML simplifying features, and that won't be a turnoff for DBAs. Many of us are very Bash orientated - what could move us away from this addiction?
What are people's opinions on this?
thanks!
Chris | Which cross platform scripting language should we adopt for a group of DBAs? | 0 | 1 | 0 | 3,213 |
3,564,177 | 2010-08-25T08:47:00.000 | 4 | 0 | 0 | 1 | python,scala,groovy,shell,jython | 3,565,446 | 6 | false | 0 | 0 | The XML thing almost calls for Scala. Now, I love Scala, but I suggest Python here. | 5 | 6 | 0 | I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and support customers on Windows, Solaris and Linux servers.
Many of the tasks we do on a frequent basis are insufficiently automated, and where they are, tend to be much more automated via shell scripts, with little equivalent functionality on Windows. Unfortunately, we now have this problem of redeveloping scripts and so on, on two platforms. So, I wish for us to choose a cross platform language to script in, instead of using Bash and awkwardly translating to Cygwin or Batch files where necessary.
It would need to be:
Dynamic (so don't suggest Java or C!)
Easily available on each platform (Windows, Solaris, Linux, perhaps AIX)
Require very little in the way of setup (root access not always available!)
Be easy for shell scripters, i.e. DBAs, to adopt, who are not hardcore developers.
Be easy to understand other people's code
Friendly with SQL Server and Oracle, without messing around.
A few nice XML features wouldn't go amiss.
It would be preferable if it would run on the JVM, since this will almost always be installed on every server (certainly on all application servers) and we have many Java developers in our company, so sticking to the JVM makes sense. This isn't exclusive though, since I know Python is a very viable language here.
I have created a list of options, but there may be more: Groovy, Scala, Jython, Python, Ruby, Perl.
No one has much experience of any, except I have quite a lot of Java and Groovy experience myself. We are looking for something dynamic, easy to pick up, will work with both SQL server and Oracle effortlessly, has some XML simplifying features, and that won't be a turnoff for DBAs. Many of us are very Bash orientated - what could move us away from this addiction?
What are people's opinions on this?
thanks!
Chris | Which cross platform scripting language should we adopt for a group of DBAs? | 0.132549 | 1 | 0 | 3,213 |
3,564,177 | 2010-08-25T08:47:00.000 | 5 | 0 | 0 | 1 | python,scala,groovy,shell,jython | 3,568,609 | 6 | false | 0 | 0 | I think your best three options are Groovy, Python, and Scala. All three let you write code at a high level (compared to C/Java). Python has its own perfectly adequate DB bindings, and Groovy and Scala can use ones made for Java.
The advantages of Python are that it is widely used already, so there are tons of tools, libraries, expertise, etc. available around it. It has a particularly clean syntax, which makes working with it aesthetically pleasing. The disadvantages are that it is slow (which may not be an issue for you), untyped (so you have runtime errors instead of compile-time errors), and you can't really switch back and forth between Jython and Python, so you have to pick whether you want the large amount of Python stuff, or the huge amount of Java stuff, minus a lot of the nice Python stuff.
The advantages of Groovy are that you know it already and it interoperates well with Java libraries. Its disadvantages are also slowness and lack of static typing. (So in contrast to Python, the choice is: do you value Python's clean syntax and wide adoption more, or do you value the vast set of Java libraries more in a language made to work well in that environment?)
The advantages of Scala are that it is statically typed (i.e. if the code gets past the compiler, it has a greater chance of working), is fast (as fast as Java if you care to work hard enough), and interoperates well with Java libraries. The disadvantages are that it imposes a bit more work on you to make the static typing work (though far, far less than Java while simultaneously being more safe), and that the canonical style for Scala is a hybrid object/functional blend that feels more different than the other two (and thus requires more training to use at full effectiveness IMO). In contrast to Groovy, the question would be whether familiarity and ease of getting started is more important than speed and correctness.
Personally, I now do almost all of my work in Scala because my work requires speed and because the compiler catches those sort of errors in coding that I commonly make (so it is the only language I've used where I am not surprised when large blocks of code run correctly once I get them to compile). But I've had good experiences with Python in other contexts--interfacing with large databases seems like a good use-case.
(I'd rule out Perl as being harder to maintain with no significant benefits over e.g. Python, and I'd rule out Ruby as being not enough more powerful than Python to warrant the less-intuitive syntax and lower rate of adoption/tool availability.) | 5 | 6 | 0 | I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and support customers on Windows, Solaris and Linux servers.
Many of the tasks we do on a frequent basis are insufficiently automated, and where they are, tend to be much more automated via shell scripts, with little equivalent functionality on Windows. Unfortunately, we now have this problem of redeveloping scripts and so on, on two platforms. So, I wish for us to choose a cross platform language to script in, instead of using Bash and awkwardly translating to Cygwin or Batch files where necessary.
It would need to be:
Dynamic (so don't suggest Java or C!)
Easily available on each platform (Windows, Solaris, Linux, perhaps AIX)
Require very little in the way of setup (root access not always available!)
Be easy for shell scripters, i.e. DBAs, to adopt, who are not hardcore developers.
Be easy to understand other people's code
Friendly with SQL Server and Oracle, without messing around.
A few nice XML features wouldn't go amiss.
It would be preferable if it would run on the JVM, since this will almost always be installed on every server (certainly on all application servers) and we have many Java developers in our company, so sticking to the JVM makes sense. This isn't exclusive though, since I know Python is a very viable language here.
I have created a list of options, but there may be more: Groovy, Scala, Jython, Python, Ruby, Perl.
No one has much experience of any, except I have quite a lot of Java and Groovy experience myself. We are looking for something dynamic, easy to pick up, will work with both SQL server and Oracle effortlessly, has some XML simplifying features, and that won't be a turnoff for DBAs. Many of us are very Bash orientated - what could move us away from this addiction?
What are people's opinions on this?
thanks!
Chris | Which cross platform scripting language should we adopt for a group of DBAs? | 0.16514 | 1 | 0 | 3,213 |
3,564,177 | 2010-08-25T08:47:00.000 | 6 | 0 | 0 | 1 | python,scala,groovy,shell,jython | 3,564,413 | 6 | false | 0 | 0 | You can opt for Python. Its dynamic(interpreted) , is available on Windows/Linux/Solaris, has easy to read syntax so that your code maintenance is easy. There modules/libraries for Oracle interaction and various other database servers as well. there are also library support for XML. All 7 points are covered. | 5 | 6 | 0 | I wanted to get the community's feedback on a language choice our team is looking to make in the near future. We are a software developer, and I work in a team of Oracle and SQL Server DBAs supporting a cross platform Java application which runs on Oracle Application Server. We have SQL Server and Oracle code bases, and support customers on Windows, Solaris and Linux servers.
Many of the tasks we do on a frequent basis are insufficiently automated, and where they are, tend to be much more automated via shell scripts, with little equivalent functionality on Windows. Unfortunately, we now have this problem of redeveloping scripts and so on, on two platforms. So, I wish for us to choose a cross platform language to script in, instead of using Bash and awkwardly translating to Cygwin or Batch files where necessary.
It would need to be:
Dynamic (so don't suggest Java or C!)
Easily available on each platform (Windows, Solaris, Linux, perhaps AIX)
Require very little in the way of setup (root access not always available!)
Be easy for shell scripters, i.e. DBAs, to adopt, who are not hardcore developers.
Be easy to understand other people's code
Friendly with SQL Server and Oracle, without messing around.
A few nice XML features wouldn't go amiss.
It would be preferable if it would run on the JVM, since this will almost always be installed on every server (certainly on all application servers) and we have many Java developers in our company, so sticking to the JVM makes sense. This isn't exclusive though, since I know Python is a very viable language here.
I have created a list of options, but there may be more: Groovy, Scala, Jython, Python, Ruby, Perl.
No one has much experience of any, except I have quite a lot of Java and Groovy experience myself. We are looking for something dynamic, easy to pick up, will work with both SQL server and Oracle effortlessly, has some XML simplifying features, and that won't be a turnoff for DBAs. Many of us are very Bash orientated - what could move us away from this addiction?
What are people's opinions on this?
thanks!
Chris | Which cross platform scripting language should we adopt for a group of DBAs? | 1 | 1 | 0 | 3,213 |
3,567,520 | 2010-08-25T15:23:00.000 | 1 | 0 | 1 | 0 | python,emacs,code-formatting,perl-tidy | 3,567,599 | 4 | false | 0 | 0 | There is a reindent.py script distributed with python in the scripts directory. | 1 | 4 | 0 | Coming from Perl I've been used to hitting C-c t to reformat my code according to pre-defined Perl::Tidy rules. Now, with Python I'm astonished to learn that there is nothing that even remotely resembles the power of Perl::Tidy. PythonTidy 1.20 looks almost appropriate, but barfed at first mis-aligned line ("unexpected indent").
In particular, I'm looking for the following:
Put PEP-8 into use as far as possible (the following items are essentially derivations of this one)
Convert indentation tabs to spaces
Remove trailing spaces
Break up code according to the predefined line-length as far as it goes (Eclipse-style string splitting and splitting method chains)
Normalize whitespace around
(bonus feature, optional) Re-format code including indentation.
Right now, I'm going throught someone else's code and correct everything pep8 and pyflakes tell me, which is mostly "remove trailing space" and "insert additional blank line". While I know that re-indentation is not trivial in Python (even though it should be possible just by going through the code and remembering the indentation), other features seem easy enough that I can't believe nobody has implemented this before.
Any recommendations?
Update: I'm going to take a deeper look at PythonTidy, since it seems to go into the right direction. Maybe I can find out why it barfs at me. | Which is the closest Python equivalent to Perl::Tidy? | 0.049958 | 0 | 0 | 1,639 |
3,568,371 | 2010-08-25T16:54:00.000 | 3 | 1 | 0 | 0 | python | 3,568,664 | 4 | false | 0 | 0 | You have a few options:
As Radomir mentioned, Cython might be a good choice: it's essentially a restricted Python with type declarations, automatically translated into C then compiled for execution.
If you want to use pure C, you can write a Python extension module using the Python C API. This is a good way to go if you need to manipulate Python data structures in your C code. Using the Python C API, you write in C, but with full access to the Python types and methods.
Or, you can write a pure C dll, then invoke it with ctypes. This is a good choice if you don't need any access to Python data structures in your C code. With this technique, your C code only deals with C types, and your Python code has to understand how to use ctypes to get at that C data. | 1 | 0 | 0 | i have prepared a project in python language ie a TEXT TO SPEECH synthesizer. Which took a total on 1500 lines of code.
But there few parts of code due to which it is taking so much time to run the code, i want to replace that parts of code in C/c++ lang so that it runs faster.
So i want to know how can i run these parts of code in C++ or improve its speed in any other way??
please suggest, | how to replicate parts of code in python into C to execution faster? | 0.148885 | 0 | 0 | 106 |
3,568,458 | 2010-08-25T17:05:00.000 | 0 | 0 | 0 | 0 | python,open-source,kml,google-earth | 4,406,874 | 5 | false | 0 | 0 | You could conceivably use Matplotlib and its toolkit Basemap to plot the images on a map (if you can retrieve the background map image that the user wants...). | 1 | 7 | 0 | Are there any open source libraries (preferably python) that will convert a kml file to an image file?
I have an open source web-based application that allows users to draw shapes on a Google Earth Map, and I would like to provide them with a pdf that contains their map with the shapes that they have drawn.
Right now the users are provided instructions for using either Print Screen or exporting the kml, but the former seems a little lame and the latter doesn't give them an image unless they have access to other software.
Is this a pipe dream? | programmatically converting kml to image | 0 | 0 | 0 | 7,001 |
3,570,111 | 2010-08-25T20:53:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 3,570,139 | 2 | false | 1 | 0 | The GAE development data store is only functionally equivalent to the production data store. It's really just a file (or set of files) on your local disk simulating BigTable. So if you abort it in the middle of doing something important, it could end up in an inconsistent state.
If you're concerned about this, you can easily back up your local data store and restore it if this happens. | 1 | 0 | 0 | I'm testing my app with the development server.
When I manually interrupt a request, it sometimes clears the datastore.
This clears even models that are not modified by my request, like users, etc.
Any idea why is this?
Thanks | Crash in development server clears datastore? | 0 | 0 | 0 | 61 |
3,570,823 | 2010-08-25T22:48:00.000 | 3 | 1 | 1 | 0 | python,global,static-methods | 3,570,851 | 3 | false | 0 | 0 | Make them module-level functions, and prefix them with a single underscore so that consumers understand that they are for private use. | 2 | 9 | 0 | So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class).
Is there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something? | Static method vs module function in python | 0.197375 | 0 | 0 | 2,735 |
3,570,823 | 2010-08-25T22:48:00.000 | 3 | 1 | 1 | 0 | python,global,static-methods | 3,571,114 | 3 | false | 0 | 0 | If they are not useful outside of the class, what is the motivation to make them module methods? Keeping them as static method makes the name space cleaner.
The only advantage to move it outside maybe so that people can reference them without using qualified them the class name. Say you have a log method that got reference in a ton of places, this may make sense as a stylistic choice. | 2 | 9 | 0 | So I have a class in a module that has some static methods. A couple of these static methods just do crc checks and stuff, and they're not really useful outside of the class (I would just make them private static methods in java or C++). I'm wondering if I should instead make them global class functions (outside of the class).
Is there any benefit for doing it either way? The class is being imported by from module import class so I'm not worried about having those modules pulled in as well. But should I just make them class methods so that from module import * is safer or something? | Static method vs module function in python | 0.197375 | 0 | 0 | 2,735 |
3,571,233 | 2010-08-26T00:22:00.000 | 2 | 0 | 0 | 0 | python,selenium,browser-automation | 3,573,288 | 3 | true | 1 | 0 | There's a Selenium.getHtmlSource() method in Java, most likely it is also available in Python. It returns the source of the current page as string, so you can do whatever you want with it | 1 | 3 | 0 | I'm not sure how to find this information, I have found a few tutorials so far about using Python with selenium but none have so much as touched on this.. I am able to run some basic test scripts through python that automate selenium but it just shows the browser window for a few seconds and then closes it.. I need to get the browser output into a string / variable (ideally) or at least save it to a file so that python can do other things on it (parse it, etc).. I would appreciate if anyone can point me towards resources on how to do this. Thanks | Selenium with Python, how do I get the page output after running a script? | 1.2 | 0 | 1 | 4,318 |
3,571,495 | 2010-08-26T01:41:00.000 | 0 | 1 | 0 | 0 | python,turbogears,psycopg | 3,571,749 | 1 | true | 0 | 0 | Problem solved (to a point). I was running 64 bit python from Aptana Studio and 32 bit python on the command line. By forcing Aptana to use 32 bit python, the libraries work again and all is happy. | 1 | 0 | 0 | I have been developing under Python/Snowleopard happily for the part 6 months. I just upgraded Python to 2.6.5 and a whole bunch of libraries, including psycopg2 and Turbogears. I can start up tg-admin and run some queries with no problems. Similarly, I can run my web site from the command line with no problems.
However, if I try to start my application under Aptana Studio, I get the following exception while trying to import psychopg2:
('dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID\n Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so\n Expected in: flat namespace\n in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/psycopg2/_psycopg.so',)
This occurs after running the following code:
try:
import psycopg2 as psycopg
except ImportError as ex:
print "import failed :-( xxxxxxxx = "
print ex.args
I have confirmed that the same version of python is being run as follows:
import sys
print "python version: ", sys.version_info
Does anyone have any ideas? I've seem some references alluding to this being a 64-bit issue.
- dave | Psycopg2 under osx works on commandline but fails in Aptana studio | 1.2 | 1 | 0 | 296 |
3,571,819 | 2010-08-26T03:18:00.000 | 0 | 0 | 0 | 0 | python,sql-server,python-3.x,py2exe | 4,062,244 | 3 | false | 0 | 0 | If you want to have portable mssql server library, you can try the module from www.pytds.com. It works with 2.5+ AND 3.1, have a good stored procedure support. It's api is more "functional", and has some good features you won't find anywhere else. | 2 | 1 | 0 | I'm using a linux machine to make a little python program that needs to input its result in a SQL Server 2000 DB.
I'm new to python so I'm struggling quite a bit to find what's the best solution to connect to the DB using python 3, since most of the libs I looked only work in python 2.
As an added bonus question, the finished version of this will be compiled to a windows program using py2exe. Is there anything I should be aware of, any changes to make?
Thanks | How to access a MS SQL Server using Python 3? | 0 | 1 | 0 | 1,786 |
3,571,819 | 2010-08-26T03:18:00.000 | 0 | 0 | 0 | 0 | python,sql-server,python-3.x,py2exe | 3,573,005 | 3 | false | 0 | 0 | I can't answer your question directly, but given that many popular Python packages and frameworks are not yet fully supported on Python 3, you might consider just using Python 2.x. Unless there are features you absolutely cannot live without in Python 3, of course.
And it isn't clear from your post if you plan to deploy to Windows only, or Windows and Linux. If it's only Windows, then you should probably just develop on Windows to start with: the native MSSQL drivers are included in most recent versions so you don't have anything extra to install, and it gives you more options, such as adodbapi. | 2 | 1 | 0 | I'm using a linux machine to make a little python program that needs to input its result in a SQL Server 2000 DB.
I'm new to python so I'm struggling quite a bit to find what's the best solution to connect to the DB using python 3, since most of the libs I looked only work in python 2.
As an added bonus question, the finished version of this will be compiled to a windows program using py2exe. Is there anything I should be aware of, any changes to make?
Thanks | How to access a MS SQL Server using Python 3? | 0 | 1 | 0 | 1,786 |
3,574,714 | 2010-08-26T11:42:00.000 | 0 | 0 | 0 | 0 | python,wxpython | 3,574,976 | 2 | false | 0 | 1 | You can send them back over a queue, or this all takes place in one instance of a class, assign the widgets to some known place in the instance for the main thread to pick them up. Signal via semaphore. | 1 | 1 | 0 | Assume i want to create 500 wxWidget like (some panels , color buttons and text ctrl etc), I have to create all this at single time but this will freeze my main thread, so i put this creation part in child thread and show some gif anim in main thread. But i was not able to get all these wxWidget object those created on my frame in child thread.
Can i get that wxWidgets (created in child thread) back in main thread.
simply just consider a case where i have to create children of a frame in child thread and main thread show animation. once child thread finish the all child created in child thread should available in main thread.
Any help is really appreciable.
I am using python 2.5, wxpython 2.8 on windowsxp. | Get object created in child thread back in main thread | 0 | 0 | 0 | 649 |
3,575,119 | 2010-08-26T12:43:00.000 | 1 | 0 | 0 | 1 | python,naming-conventions,twisted,rpc | 3,575,219 | 1 | true | 0 | 0 | First tip: Use PB... it's well designed and does exactly that
Second Tip: If the first tip isn't going to work for you, just do what PB does. On the client end a "callRemote("foo_func")" asks the server ot invoke the "foo_func" function on the server object. The server will then use "getattr(server_obj, "remote_" + "foo_func")" to find the remote method. If the method exists, it's called. Otherwise an error is returned. The nice thing about this design is that it completely does away with your REQUEST... CMD... constants. | 1 | 0 | 0 | I'm using twisted. I have my protocols set up so that, to send an RPC, I do protocol.send("update_status", data). To document which RPCs I've implemented, I make a separate function call for each one, so in this case I'd call REQUEST_UPDATE_STATUS(data) to send that RPC. When a protocol receives an RPC, a function gets called based on its name, in this case, CMD_UPDATE_STATUS.
The problem is that REQUEST and CMD are a bit awkward. I can mistake REQUEST as part of the command, for example, REQUEST_NEW_DATA, and that would end up triggering an RPC called 'new_data'. However, REQUEST_REQUEST_NEW_DATA is just silly.
CMD is also awkward, as a REQUEST_SEND_NEW_DATA will become CMD_SEND_NEW_DATA, which is a bit awkward.
Any tips? | Function Names for sending and receiving RPCs? | 1.2 | 0 | 0 | 60 |
3,576,071 | 2010-08-26T14:24:00.000 | 0 | 0 | 0 | 0 | python,user-interface,wxpython | 3,579,195 | 2 | false | 0 | 1 | Does calling event.GetEventObject() in your event handler give you the object you need? | 1 | 0 | 0 | So, for example I draw some objects on wx.PaintDC, such as lines and rectangles.
Now I want next: on mouse click I wont know which object was clicked.
Of course, I can see what object is the closest, but what about more exact answer?
Maybe even not standart wx.DC, but such things as FloatCanvas or something like this.
So, what's the best solution? | What is the best solution to bind objects in wx.DC? | 0 | 0 | 0 | 100 |
3,576,430 | 2010-08-26T15:00:00.000 | 1 | 0 | 0 | 0 | python,numpy | 3,605,012 | 2 | true | 0 | 0 | It appears that this may have been an error from using the 32-bit version of NumPy and not the 64 bit. For whatever reason, though the program has no problem keeping the array in memory, it trips up when writing the array to a file if the number of elements in the array is greater than 2^32. | 2 | 0 | 1 | I've never seen this error before, and none of the hits on Google seem to apply. I've got a very large NumPy array that holds Boolean values. When I try writing the array using numpy.dump(), I get the following error:
SystemError: NULL result without error in PyObject_Call
The array is initialized with all False values, and the only time I ever access it is to set some of the values to True, so I have no idea why any of the values would be null.
When I try running the same program with a smaller array, I get no error. However, since the error occurs at the writing step, I don't think that it's a memory issue. Has anybody else seen this error before? | Python/Numpy error: NULL result without error in PyObject_Call | 1.2 | 0 | 0 | 3,309 |
3,576,430 | 2010-08-26T15:00:00.000 | 1 | 0 | 0 | 0 | python,numpy | 3,576,712 | 2 | false | 0 | 0 | That message comes directly from the CPython interpreter (see abstract.c method PyObject_Call). You may get a better response on a Python or NumPy mailing list regarding that error message because it looks like a problem in C code.
Write a simple example to demonstrating the problem and you should be able to narrow the issue down to a module then a method. | 2 | 0 | 1 | I've never seen this error before, and none of the hits on Google seem to apply. I've got a very large NumPy array that holds Boolean values. When I try writing the array using numpy.dump(), I get the following error:
SystemError: NULL result without error in PyObject_Call
The array is initialized with all False values, and the only time I ever access it is to set some of the values to True, so I have no idea why any of the values would be null.
When I try running the same program with a smaller array, I get no error. However, since the error occurs at the writing step, I don't think that it's a memory issue. Has anybody else seen this error before? | Python/Numpy error: NULL result without error in PyObject_Call | 0.099668 | 0 | 0 | 3,309 |
3,577,335 | 2010-08-26T16:39:00.000 | 1 | 0 | 0 | 0 | python,gtk,pygtk | 3,580,114 | 1 | true | 0 | 1 | The widgets don't remember their original state; you have to set them all back one by one. Give labels their original text, clear the tree views by setting their model to None.
Perhaps it is better to destroy your window and rebuild it from your Glade file if you have one? | 1 | 0 | 0 | I would like to implement a button "New" that would work the same as File>New in most applications - that is: resets all the labels, treeviews, etc. to the original state.
Thank you, Tomas | How do I restore default settings of an application in Gtk (set all the widgets to the state as if the application was restarted)? | 1.2 | 0 | 0 | 263 |
3,577,652 | 2010-08-26T17:18:00.000 | 2 | 0 | 0 | 0 | python,xml | 3,577,694 | 2 | false | 0 | 0 | BeautifulSoup is your best bet in this case. I suggest profiling before ruling out BeautifulSoup altogether. | 1 | 4 | 0 | A sever I can't influence sends very broken XML.
Specifically, a Unicode WHITE STAR would get encoded as UTF-8 (E2 98 86) and then translated using a Latin-1 to HTML entity table. What I get is â 98 86 (9 bytes) in a file that's declared as utf-8 with no DTD.
I couldn't configure W3C tidy in a way that doesn't garble this irreversibly. I only found how to make lxml skip it silently. SAX uses Expat, which cannot recover after encountering this. I'd like to avoid BeautifulSoup for speed reasons.
What else is there? | How to parse broken XML in Python? | 0.197375 | 0 | 1 | 1,950 |
3,577,994 | 2010-08-26T17:57:00.000 | 0 | 0 | 0 | 0 | python,web-services,rest | 3,578,028 | 5 | false | 0 | 0 | Sure, you can use any web framework you like, just set the content-type header to the mime type you need. For generating json I recommend the simplejson module (ranamed to json and included in the standard library since 2.6), for handling XML the lxml library is very nice. | 1 | 2 | 0 | Is it possible to create REST Web Services, that returns JSON or XML, using Python ?
Could you give me some recomandations ?
Thank you. | Creating REST Web Services with Python | 0 | 0 | 1 | 12,155 |
3,578,822 | 2010-08-26T19:33:00.000 | 1 | 0 | 0 | 0 | c#,python,django,asp.net-mvc-2 | 3,578,887 | 4 | false | 1 | 0 | I would create a small app to try each for a day or two and then choose.
I can't speak for Django, but here are some Asp.Net MVC benefits
Tight integration with other Microsoft technologies
Uses jquery out of the box
Choice of several server-side languages
Very flexible (choice of unit test framework, view engine, model architecture etc)
and a potential negative
Might take extra work getting it running on anything other than Windows | 4 | 0 | 0 | I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2.
Can you say me the difference between them and what is so interesting? | I can`t decide what to select: ASP.NET MVC 2 (C#) or Django (Python)? | 0.049958 | 0 | 0 | 362 |
3,578,822 | 2010-08-26T19:33:00.000 | 4 | 0 | 0 | 0 | c#,python,django,asp.net-mvc-2 | 3,578,857 | 4 | true | 1 | 0 | Try both, then decide. | 4 | 0 | 0 | I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2.
Can you say me the difference between them and what is so interesting? | I can`t decide what to select: ASP.NET MVC 2 (C#) or Django (Python)? | 1.2 | 0 | 0 | 362 |
3,578,822 | 2010-08-26T19:33:00.000 | 1 | 0 | 0 | 0 | c#,python,django,asp.net-mvc-2 | 3,579,129 | 4 | false | 1 | 0 | What reasons lead you to choose those
two frameworks?
What reasons lead you to choose those
two languages?
If you don't like the answers, then keep looking. Otherwise...
Do you want to be on a
non-Microsoft web stack? Go Django.
Do you want to interface with lots of other
Microsoft web stack technologies? Go
MVC.
Do you want complied language speed? Go C#.
Do you want interpreted language portability? Go Python. | 4 | 0 | 0 | I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2.
Can you say me the difference between them and what is so interesting? | I can`t decide what to select: ASP.NET MVC 2 (C#) or Django (Python)? | 0.049958 | 0 | 0 | 362 |
3,578,822 | 2010-08-26T19:33:00.000 | 2 | 0 | 0 | 0 | c#,python,django,asp.net-mvc-2 | 3,578,889 | 4 | false | 1 | 0 | Well, I'm using both and found both to be state of the art, easy to learn, fast and easy to install.
Maybe don't look at it from a technical standpoint but from the context. ASP.NET needs a Windows Server, ASP.NET and an IIS installed. You have the license for that? Django on the other hand is open source runs on cheap but fast linux machines and provides you with the Python Language and it's vast easy to install moduls.
If you don't know Python or C# maybe Django is the better way to go. Djangos Documentation is great and has a great tutorial, which is yet to be found on the ASP.NET MVC side.
Well, the conclusion is: Try both :) And if you're gonna use ASP.NET MVC, watch the Nerddinner Sessions (PDC) by Scott Hanselman and Phil Haack. | 4 | 0 | 0 | I`m learning programming languages. And I decide that I need to lear a new web framework. I have 2 candidates: Django or ASP.NET MVC 2.
Can you say me the difference between them and what is so interesting? | I can`t decide what to select: ASP.NET MVC 2 (C#) or Django (Python)? | 0.099668 | 0 | 0 | 362 |
3,579,568 | 2010-08-26T21:13:00.000 | 0 | 0 | 1 | 0 | python,user-interface,dialog,filechooser | 68,347,357 | 11 | false | 0 | 0 | I resolved all problem related to
from tkinter import * from tkinter import filedialog
by just migrating from pycharm IDE to visual studio code IDE and every problem is solved. | 1 | 164 | 0 | I would like to get file path as input in my Python console application.
Currently I can only ask for full path as an input in the console.
Is there a way to trigger a simple user interface where users can select file instead of typing the full path? | Choosing a file in Python with simple Dialog | 0 | 0 | 0 | 345,604 |
3,580,778 | 2010-08-27T01:45:00.000 | 0 | 0 | 0 | 0 | python,django,forms,video,file-upload | 3,583,993 | 3 | false | 1 | 0 | Additionaly have a look at jquery uploadify. It's pretty useful for large file uploads because it display the progress of the download. | 1 | 1 | 0 | I want a user to be able to upload a video from their computer or record it right from their webcam, then fill out other information with a form. I'm writing this app with Django. | How do you create a video file upload form with Django? | 0 | 0 | 0 | 3,028 |
3,585,428 | 2010-08-27T14:57:00.000 | 2 | 0 | 0 | 0 | python,django,database-design,date,time | 3,585,722 | 4 | true | 1 | 0 | If you think your solution is complicated, it's not. Modeling sick/vacation days as accounts that are linked to employees is a very good idea and can be dead easy.
In the simplest case, you can have a "transactions" table, and a "account" table, such that re-running all the transactions from the beginning of the year (for each account) will yield a sum that exactly matches the balance.
Transactions
ID | Account | Delta | Timestamp
Account
ID | Name | Employee | Year | Balance
The transactions provide an audit trail, and the balance provides a point of reference for your next transaction. By ensuring the two match, you've ensured consistency (though, not necessarily correctness - that's got to be checked with unit tests on each type of transaction, i.e. deposit, withdrawal)
I'd recommend a "Transaction Detail" table that refers to the Transactions.ID, and includes all the nice stuff you want like who initiated it, notes, etc. | 3 | 3 | 0 | I'm using Python/Django, but this is more about the "data model" and how I interact with the information - I really just want to know if I'm crazy here.
I'm working on a small app at my company (~55 employees) that will keep track of available Vacation/Sick time. Part of the purpose is to integrate "self-service" into our intranet, so that employees can submit "Time Off Requests" electronically, instead of filling out and handing in paper to HR.
Obviously, this app needs to keep a running balance per employee, and will be validating that the employee has enough Vacation remaining for whatever they're requesting.
Like with financial/accounting software, I know that I shouldn't necessarily be storing float values, or just keeping a single running balance.
My idea is to use a database table structure like the following to store time "credits" and "debits":
Employee | Year | Credit/Debit | Amount | Timestamp
'Year' would be the year to which the credit/debit belong, because Vacation and Sick time are handled on a yearly basis, not on a running balance per employee.
To determine the employees available Vacation/Sick time, I would get the 'transactions' for the employee for the given year, and find the balance.
I know I'm leaving out lots of information, but I was wondering: Does this seem like a reasonable way to go about this, being as that it needs to be very accurate, or am I completely over-complicating this? | Programmatically managing a 'balance' of time (sick/vacation) | 1.2 | 0 | 0 | 1,331 |
3,585,428 | 2010-08-27T14:57:00.000 | 0 | 0 | 0 | 0 | python,django,database-design,date,time | 3,585,669 | 4 | false | 1 | 0 | I also agree it's a good start.
I don't see any fields for approval / disapproval. If this app is meant to be used also by HR, then their decisions need to be expressed in your model as well.
If HR is being taken out of the picture (which I doubt, but maybe) then there's no need to do this; the app can keep track of requests and the leave balance and say immediately whether the request is valid or not. But I suspect it can't be this simple. :) | 3 | 3 | 0 | I'm using Python/Django, but this is more about the "data model" and how I interact with the information - I really just want to know if I'm crazy here.
I'm working on a small app at my company (~55 employees) that will keep track of available Vacation/Sick time. Part of the purpose is to integrate "self-service" into our intranet, so that employees can submit "Time Off Requests" electronically, instead of filling out and handing in paper to HR.
Obviously, this app needs to keep a running balance per employee, and will be validating that the employee has enough Vacation remaining for whatever they're requesting.
Like with financial/accounting software, I know that I shouldn't necessarily be storing float values, or just keeping a single running balance.
My idea is to use a database table structure like the following to store time "credits" and "debits":
Employee | Year | Credit/Debit | Amount | Timestamp
'Year' would be the year to which the credit/debit belong, because Vacation and Sick time are handled on a yearly basis, not on a running balance per employee.
To determine the employees available Vacation/Sick time, I would get the 'transactions' for the employee for the given year, and find the balance.
I know I'm leaving out lots of information, but I was wondering: Does this seem like a reasonable way to go about this, being as that it needs to be very accurate, or am I completely over-complicating this? | Programmatically managing a 'balance' of time (sick/vacation) | 0 | 0 | 0 | 1,331 |
3,585,428 | 2010-08-27T14:57:00.000 | 0 | 0 | 0 | 0 | python,django,database-design,date,time | 3,585,570 | 4 | false | 1 | 0 | This looks like a good start. A couple of points:
The credits would be autogenerated by the system at the begining of the year, and debits would be created by employees. Should there be a field to indicate who/what created the transaction?
Do you have a mechanism for indicating what kind of time off is requested? I don't know what your company is like but some companies treat vacation and sick time differently. Then there's also caregiver time, time off for compassion grounds (such as a relative dies), time off for civic and statutory holidays, time off for religions holidays, time off for.... well you get the idea. Maybe you want different types of time off to be worth different amounts of credit. Some organizations do that. Do you plan to track these different time-off codes as well? Is it something that you should plan for if you think it will be an issue in the future? | 3 | 3 | 0 | I'm using Python/Django, but this is more about the "data model" and how I interact with the information - I really just want to know if I'm crazy here.
I'm working on a small app at my company (~55 employees) that will keep track of available Vacation/Sick time. Part of the purpose is to integrate "self-service" into our intranet, so that employees can submit "Time Off Requests" electronically, instead of filling out and handing in paper to HR.
Obviously, this app needs to keep a running balance per employee, and will be validating that the employee has enough Vacation remaining for whatever they're requesting.
Like with financial/accounting software, I know that I shouldn't necessarily be storing float values, or just keeping a single running balance.
My idea is to use a database table structure like the following to store time "credits" and "debits":
Employee | Year | Credit/Debit | Amount | Timestamp
'Year' would be the year to which the credit/debit belong, because Vacation and Sick time are handled on a yearly basis, not on a running balance per employee.
To determine the employees available Vacation/Sick time, I would get the 'transactions' for the employee for the given year, and find the balance.
I know I'm leaving out lots of information, but I was wondering: Does this seem like a reasonable way to go about this, being as that it needs to be very accurate, or am I completely over-complicating this? | Programmatically managing a 'balance' of time (sick/vacation) | 0 | 0 | 0 | 1,331 |
3,586,071 | 2010-08-27T16:05:00.000 | 4 | 0 | 0 | 0 | python,user-interface,pygtk,gettext,glade | 3,588,790 | 1 | true | 0 | 1 | You should be able to create a *.pot file from a *.glade file using intltool-extract --type=gettext/glade foo.glade, and intltool supposedly knows what is translatable.
Also, I suggest you look into GtkBuilder if you didn't do that already (you can save GtkBuilder interface files from recent Glade 3 versions, and you won't need the extra libglade anymore). | 1 | 7 | 0 | I have made an application using Glade and Python and I would like to make several localizations.
I know how to localize strings that are in the Python code, I just encapsule all the strings that are supposed to be localized with _() and than specify the translation of the string in a .po file.
But how do I tell a string that is built with Glade that it should be localizable (for example labels, menu items, button labels, ...)?
I am using gettext for the localization.
Thank you, Tomas | Localization of GUI built with Glade and Python (Gtk) | 1.2 | 0 | 0 | 1,203 |
3,586,295 | 2010-08-27T16:34:00.000 | 0 | 1 | 0 | 0 | python,urllib2,urlopen | 38,239,971 | 5 | false | 0 | 0 | If you make changes and test the behaviour from browser and from urllib, it is easy to make a stupid mistake.
In browser you are logged in, but in urllib.urlopen your app can redirect you always to the same login page, so if you just see the page size or the top of your common layout, you could think that your changes have no effect. | 3 | 13 | 0 | They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right? | Does urllib2.urlopen() cache stuff? | 0 | 0 | 1 | 12,290 |
3,586,295 | 2010-08-27T16:34:00.000 | 10 | 1 | 0 | 0 | python,urllib2,urlopen | 3,586,796 | 5 | true | 0 | 0 | So I wonder it does cache stuff somewhere, right?
It doesn't.
If you don't see new data, this could have many reasons. Most bigger web services use server-side caching for performance reasons, for example using caching proxies like Varnish and Squid or application-level caching.
If the problem is caused by server-side caching, usally there's no way to force the server to give you the latest data.
For caching proxies like squid, things are different. Usually, squid adds some additional headers to the HTTP response (response().info().headers).
If you see a header field called X-Cache or X-Cache-Lookup, this means that you aren't connected to the remote server directly, but through a transparent proxy.
If you have something like: X-Cache: HIT from proxy.domain.tld, this means that the response you got is cached. The opposite is X-Cache MISS from proxy.domain.tld, which means that the response is fresh. | 3 | 13 | 0 | They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right? | Does urllib2.urlopen() cache stuff? | 1.2 | 0 | 1 | 12,290 |
3,586,295 | 2010-08-27T16:34:00.000 | -2 | 1 | 0 | 0 | python,urllib2,urlopen | 3,936,916 | 5 | false | 0 | 0 | I find it hard to believe that urllib2 does not do caching, because in my case, upon restart of the program the data is refreshed. If the program is not restarted, the data appears to be cached forever. Also retrieving the same data from Firefox never returns stale data. | 3 | 13 | 0 | They didn't mention this in python documentation. And recently I'm testing a website simply refreshing the site using urllib2.urlopen() to extract certain content, I notice sometimes when I update the site urllib2.urlopen() seems not get the newly added content. So I wonder it does cache stuff somewhere, right? | Does urllib2.urlopen() cache stuff? | -0.07983 | 0 | 1 | 12,290 |
3,586,776 | 2010-08-27T17:38:00.000 | 0 | 0 | 1 | 1 | python,unix,scripting,python-3.x,shebang | 3,586,813 | 8 | false | 0 | 0 | As I understand different distros will be in different locations in your drive. Here are some suggestions that come to mind -
You could use UNIX alias to create shortcuts pointing to the different distros. Eg: alias py2="/usr/bin/python2.X". So when you run your script you could use py2 xx.py
Or other way could be to modify your PYTHON_PATH environment variable.
Or if I am not wrong there is a provision in sys module to get the current python version number. You could get that & deal appropriately.
This should do it... | 4 | 22 | 0 | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific version (eg. 2.6) of python, but that would rule out people who don't have that version.
It seems to me that this is going to be increasingly a problem when distros will start putting python3 as the default python interpreter. | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? | 0 | 0 | 0 | 1,239 |
3,586,776 | 2010-08-27T17:38:00.000 | 2 | 0 | 1 | 1 | python,unix,scripting,python-3.x,shebang | 3,587,849 | 8 | false | 0 | 0 | Depends on how you're distributing it, I guess.
If you're using a normal setup.py file to manage your distribution, have it bomb out if the user is trying to install it in Python 3.
Once it's installed, the shebang of the console script created by (say) setuptools will likely be linked to the specific interpreter used to install it.
If you're doing something weird for your installation, you can in whatever installation script you're using look for python interpreters and store a choice. You might first check whether whatever is called "python" is a 2.x. If not, check for "python2.7", "python2.6", etc to see what's available. | 4 | 22 | 0 | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific version (eg. 2.6) of python, but that would rule out people who don't have that version.
It seems to me that this is going to be increasingly a problem when distros will start putting python3 as the default python interpreter. | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? | 0.049958 | 0 | 0 | 1,239 |
3,586,776 | 2010-08-27T17:38:00.000 | 2 | 0 | 1 | 1 | python,unix,scripting,python-3.x,shebang | 3,587,790 | 8 | false | 0 | 0 | Not quite the same situation, but the company I work for has an app that can run Python scripts (among its many features). After numerous support issues involving Python installations on various platforms, we decided to just install our own Python interpreter with the app. That way we know exactly where it is installed and what version it is. This approach may be too heavyweight for your needs (the Python package is only about 10% of our app's bits) but it definitely works. | 4 | 22 | 0 | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific version (eg. 2.6) of python, but that would rule out people who don't have that version.
It seems to me that this is going to be increasingly a problem when distros will start putting python3 as the default python interpreter. | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? | 0.049958 | 0 | 0 | 1,239 |
3,586,776 | 2010-08-27T17:38:00.000 | 8 | 0 | 1 | 1 | python,unix,scripting,python-3.x,shebang | 3,587,731 | 8 | true | 0 | 0 | This is a bit of a messy issue during what will be a very long transition time period. Unfortunately, there is no fool-proof, cross-platform way to guarantee which Python version is being invoked, other than to have the Python script itself check once started. Many, if not most, distributions that ship Python 3 are ensuring the generic python command is aliased by default to the most recent Python 2 version while python3 is aliased to the most recent Python 3. Those distributions that don't should be encouraged to do so. But there is no guarantee that a user won't override that. I think the best practice available for the foreseeable future is to for packagers, distributors, and users to assume python refers to Python 2 and, where necessary, build a run-time check into the script. | 4 | 22 | 0 | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? On my distro, I can use #!/usr/bin/env python2 as the shebang, but it seems not all distros ship "python2". I could explicitly call a specific version (eg. 2.6) of python, but that would rule out people who don't have that version.
It seems to me that this is going to be increasingly a problem when distros will start putting python3 as the default python interpreter. | Is there a standard way to make sure a python script will be interpreted by python2 and not python3? | 1.2 | 0 | 0 | 1,239 |
3,588,162 | 2010-08-27T21:12:00.000 | 0 | 0 | 1 | 0 | python,vim,indentation,highlighting | 3,588,385 | 5 | false | 0 | 0 | in vim (no plugins needed):
:set list
will display tabs as '^I' and EOL as '$' by default.
with
:set lcs=tab:>>
you'd set '^I' to '>' (see more on that by :help listchars).
i'm not sure, but there should be another option to set the tab width.
also you may set
:set autoindent
for python | 1 | 4 | 0 | I'm looking for a way in vim to easily visualize the various indent levels of python code. It would help if there was always a vertical rule at the beginning of the current line. That way I can scan down the code to see where the current block ends. Are there any plugins out there that do this? | How to show a vertical rule at the beginning of the current line? | 0 | 0 | 0 | 430 |
3,588,817 | 2010-08-27T23:49:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 42,148,664 | 10 | false | 1 | 0 | I'll restate a solution to getting permanent datastore as it worked for me (circa Feb 2017), running GoogleAppEngineLauncher on OS X v10.10.
Create the folder path for permanent datastore
In GAEL, click on the project in question e.g. PROJECTNAME
Click Edit-Application Settings
in Extra Flags field:
--datastore_path=/Users/foo/GAE_datastore/PROJECTNAME/datastore.db
Filename has to be included; in my config, datastore.db works.
Having searched all over for GAE datastore path, and head-bonked on dev_appserver.py --datastore_path command line, it was very helpful to find this.
Application Settings under the Edit menu is an odd choice, Google :-) | 5 | 11 | 0 | How can I find where my local development datastore is located? I am using the Python SDK and Linux. | Where is my local App Engine datastore? | 0 | 0 | 0 | 11,200 |
3,588,817 | 2010-08-27T23:49:00.000 | 6 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 4,180,525 | 10 | false | 1 | 0 | To find the file location for the local AppEngine datastore on MacOSX/Python, you can run the following command:
dev_appserver.py -help
Mine was at something like:
/var/folders/uP/uP1GHkGKGqO7QPq+eGMmb++++TI/-Tmp-/dev_appserver.datastore | 5 | 11 | 0 | How can I find where my local development datastore is located? I am using the Python SDK and Linux. | Where is my local App Engine datastore? | 1 | 0 | 0 | 11,200 |
3,588,817 | 2010-08-27T23:49:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 57,534,409 | 10 | false | 1 | 0 | The default location of the datastore for the platform you're running the app engine on is provided in the README that comes with the platform (at least, in the one for Linux). The README is in google_appengine_x.x.xx/google_appengine/README. This is what is says in the Linux'es one:
--datastore_path=DS_FILE Path to file to use for storing Datastore file
stub data.
(Default /tmp/dev_appserver.datastore) | 5 | 11 | 0 | How can I find where my local development datastore is located? I am using the Python SDK and Linux. | Where is my local App Engine datastore? | 0 | 0 | 0 | 11,200 |
3,588,817 | 2010-08-27T23:49:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 8,814,627 | 10 | false | 1 | 0 | Since it's top question on Google search and I spent quite amount of time searching for an answer I'll say that on Windows/Java mix DB file called local_db.bin. | 5 | 11 | 0 | How can I find where my local development datastore is located? I am using the Python SDK and Linux. | Where is my local App Engine datastore? | 0.039979 | 0 | 0 | 11,200 |
3,588,817 | 2010-08-27T23:49:00.000 | 4 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 23,270,307 | 10 | false | 1 | 0 | I use OS X Mavericks (10.9), Python 2.7.5, and Google App Engine SDK 1.9.3 (Python).
None of the above worked for me, however, referencing @alsmola's answer, I executed sudo find / | grep datastore.db and found the file in /private/var/folders/vw/7w1zhkls4gb1wd8r160c36300000gn/T/appengine.YYYY.XXXXX/datastore.db (YYYY is the project name, XXXXX is my username). | 5 | 11 | 0 | How can I find where my local development datastore is located? I am using the Python SDK and Linux. | Where is my local App Engine datastore? | 0.07983 | 0 | 0 | 11,200 |
3,588,915 | 2010-08-28T00:28:00.000 | 0 | 0 | 0 | 0 | python,qt,plugins,pyqt4,pluggable | 3,588,947 | 2 | false | 0 | 1 | Have a directory for the plugins, define an interface for those plugins, and walk the directory importing them.
I've never done this in Python, but in C the way I did it was to define a number of functions that the plugin needed to implement. The basic key elements that are necessary is the name of the things in the plugin (so that you can display them in your UI so that the user can instantiate them) and a factory to actually create the things. I suppose in Python it'd be pretty trivial to just do those as one dict that you can return from the module.
E.g. declare that all plugins must author a function called GetPluginInfo() which returns a dictionary of name:class mappings.
Actually now that I think about it you could probably just import the file and look for classes that are subclasses of whatever you care about and not require any explicit API be implemented. I haven't done a lot of that but basically you'd walk the module's dir() and test to see if each thing is a subclass of QWidget (for example). | 1 | 2 | 0 | I want to make a PyQt4 program that supports plugins. Basically I want the user to be able to write QWidget subclasses in PyQt4 and add/remove them from the main application window via a GUI. How would I do that, especially the plugin mechanism? | Pluggable Python program | 0 | 0 | 0 | 834 |
3,589,185 | 2010-08-28T02:26:00.000 | 3 | 0 | 0 | 0 | python,ubuntu,window,tkinter | 3,589,200 | 2 | true | 0 | 1 | Ubuntu's desktop manager is Gnome, which should support wm_overrideredirect as well as any other. What's going wrong for you when you try that? Can you show (by editing your Q) some as-tiny-as-possible Python/Tkinter script that does not behave the way you want, and tell us how it does behave and how you'd like to behave? | 1 | 0 | 0 | Is there a command similar to "wm_overrideredirect" for Ubuntu? I want My program to be displayed without the standard window. | Tkinter removing standard window in Ubuntu | 1.2 | 0 | 0 | 182 |
3,589,214 | 2010-08-28T02:37:00.000 | 8 | 0 | 1 | 0 | python,random | 3,589,232 | 7 | false | 0 | 0 | Generate 4 random numbers, compute their sum, divide each one by the sum and multiply by 40.
If you want Integers, then this will require a little non-randomness. | 2 | 41 | 0 | So here is the deal: I want to (for example) generate 4 pseudo-random numbers, that when added together would equal 40. How could this be dome in python? I could generate a random number 1-40, then generate another number between 1 and the remainder,etc, but then the first number would have a greater chance of "grabbing" more. | Generate random numbers summing to a predefined value | 1 | 0 | 0 | 18,669 |
3,589,214 | 2010-08-28T02:37:00.000 | 3 | 0 | 1 | 0 | python,random | 3,589,299 | 7 | false | 0 | 0 | There are only 37^4 = 1,874,161 arrangements of four integers in the range [1,37] (with repeats allowed). Enumerate them, saving and counting the permutations that add up to 40.
(This will be a much smaller number, N).
Draw uniformly distributed random integers K in the interval [0, N-1] and return the K-th permutation. This can easily be seen to guarantee a uniform distribution over the space of possible outcomes, with each sequence position identically distributed. (Many of the answers I'm seeing will have the final choice biased lower than the first three!) | 2 | 41 | 0 | So here is the deal: I want to (for example) generate 4 pseudo-random numbers, that when added together would equal 40. How could this be dome in python? I could generate a random number 1-40, then generate another number between 1 and the remainder,etc, but then the first number would have a greater chance of "grabbing" more. | Generate random numbers summing to a predefined value | 0.085505 | 0 | 0 | 18,669 |
3,589,667 | 2010-08-28T06:01:00.000 | 2 | 0 | 1 | 0 | python,windows,list | 3,589,672 | 2 | false | 0 | 0 | You can add a word to a list by calling alist.append("word") where alist is your list.
To count how many words are in the list simply use len(alist).
To check if the word isn't already in the list use if "word" not in alist:
-edit to remove references to word 'list', replacing it with 'alist' | 1 | 0 | 0 | I want to simply add some word to a list and then count how many words are in there...
And check if the word isn't in the list already.
How can I do it? | How can I add some string to a list in order to make a count word? [Python] | 0.197375 | 0 | 0 | 108 |
3,589,817 | 2010-08-28T07:08:00.000 | 2 | 0 | 0 | 0 | python,user-input,tkinter | 3,589,984 | 1 | true | 0 | 1 | UI toolkits usually have an event-driven model where the main loop is in the toolkit itself. This is probably different from your current synchronous, interactive model (where the program just pauses while waiting for input)
The best would be to try to refactor your program and factor-out the view part (look up the model-view-control design pattern). After that, it should be easy to replace your console oriented view with an tkInter based one.
(that's as specific as I can get without a concrete question) | 1 | 0 | 0 | I have an existing python script and I want to wrap it in a GUI. Since I already have tkinter installed I would like to use it if possible. At the moment my script has many places where it asks for user input using raw_input(). I would like to replace these with either a modal pop-up asking for user input or (preferably) an Entry object which responds to the enter key. | Creating a gui around a python script using Tkinter | 1.2 | 0 | 0 | 1,228 |
3,591,020 | 2010-08-28T14:10:00.000 | 1 | 0 | 1 | 0 | python,multithreading,session,cherrypy,asynchronous | 3,591,183 | 1 | true | 1 | 0 | You can create your own session type, derived from CherryPy's base session. Use its clean_up method to do your cleanup.
Look at cherrypy/lib/sessions.py for details and sample session implementations. | 1 | 0 | 0 | I'm using CherryPy to make a web-based frontend for SymPy that uses an asynchronous process library on the server side to allow for processing multiple requests at once without waiting for each one to complete. So as to allow for the frontend to function as expected, I am using one process for the entirety of each session. The client-side Javascript sends the session-id from the cookie to the server when the user submits a request, and the server-side currently uses a pair of lists, storing instances of a controller class in one and the corresponding session-id's in another, creating a new interpreter proxy and sending the input if a non-existant session-id is submitted. The only problem with this is that the proxy classes are not deleted upon the expiration of their corresponding sessions. Also, I can't see anything to retrieve the session-id for which the current request is being served.
My questions about all this are: is there any way to "connect" an arbitrary object to a CherryPy session so that it gets deleted upon session expiration, is there something I am overlooking here that would greatly simplify things, and does CherryPy's multi-threading negate the problem of synchronous reading of the stdout filehandle from the child process? | Bind arbitrary Python objects to CherryPy sessions | 1.2 | 0 | 0 | 751 |
3,593,861 | 2010-08-29T07:01:00.000 | 3 | 0 | 1 | 0 | python,jython | 12,073,652 | 5 | false | 0 | 0 | Jython really shines for dependency injection.
You know those pesky variables you have to give your program, like
file system paths
server names
ports
Jython provides a really nice way of injecting those variables by putting them in a script. It works equally well for injecting java dependencies, as well. | 2 | 6 | 0 | I recently started learning Python. Not yet ventured into coding.
During one of my learning sessions, i came accross the term Jython.
I googled it & got some information.
I would like to know if anyone has implemented any real-world program using Jython. | Real-world Jython applications | 0.119427 | 0 | 0 | 2,065 |
3,593,861 | 2010-08-29T07:01:00.000 | 2 | 0 | 1 | 0 | python,jython | 8,727,346 | 5 | false | 0 | 0 | WebSphere and WebLogic use it as their default scripting engine for administrative purposes.
A lot of other Oracle products ship it as part of their "oracle_commons" module (Oracle Universal Installer, Oracle HTTP Server etc). It's mostly version 2.2 being deployed though, which is a bit old and clunky. | 2 | 6 | 0 | I recently started learning Python. Not yet ventured into coding.
During one of my learning sessions, i came accross the term Jython.
I googled it & got some information.
I would like to know if anyone has implemented any real-world program using Jython. | Real-world Jython applications | 0.07983 | 0 | 0 | 2,065 |
3,594,631 | 2010-08-29T12:04:00.000 | 0 | 0 | 1 | 0 | python,network-programming | 3,594,735 | 2 | true | 0 | 0 | To receive messages (e.g. the UDP package suggested by the other poster or an http request), the clients would have to run a basic server on the client machine. You could use the Python xmlrpc module for example. However, a local firewall may block the inward communication.
The easiest solution, if the number of clients is moderate, will be to frequently poll the database for changes: add a column "last modification time" to your drawing table and have the clients check this field. This way the clients can find out whether they need to reload the drawing without wasting too many resources.
Edit: The last modification field could either be actively updated by the client that made a change to the drawing, or automatically updated by a database trigger. | 2 | 1 | 0 | I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database?
I would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information? | Keeping multiple clients showing up-to-date information in Python? | 1.2 | 0 | 0 | 177 |
3,594,631 | 2010-08-29T12:04:00.000 | 0 | 0 | 1 | 0 | python,network-programming | 3,594,712 | 2 | false | 0 | 0 | You could use triggers. When an information is updated send a signal (is up to you choose how, maybe just an udp packet) to all blotters that will update their information consequentially. Postgresql could be scripted using python. | 2 | 1 | 0 | I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database?
I would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information? | Keeping multiple clients showing up-to-date information in Python? | 0 | 0 | 0 | 177 |
3,595,000 | 2010-08-29T13:50:00.000 | 1 | 0 | 0 | 0 | python,variables,plugins | 3,595,398 | 1 | false | 0 | 0 | I like the way wxPython does events. Pass an event object to the plugin with what you think is the relevant data, but also provide an API for every plugin to access the full state of the application.
For example, in wxMouseEvent has x and y properties. But also (like every other event object) has get GetEventObject (and every object has GetParent ....) | 1 | 3 | 0 | I'm implementing a simple plugin framework for a little Python program and wonder what the different existing practices are for passing data to plugins.
At this stage, I see two alternatives:
pass task-specific data to plugins, don't give plugins access to any other data
pass all the data to which any plugin should have access
What are the pros and cons of these two approaches? Are there any other ways or best practices that I am unaware of? What do I have to take into consideration when deciding the way?
Note: I am asking for examples and general advice. | Python: What ways of making data available to plugins? | 0.197375 | 0 | 0 | 151 |
3,595,236 | 2010-08-29T15:03:00.000 | 3 | 0 | 0 | 0 | c#,winforms,ironpython | 3,595,266 | 3 | true | 0 | 1 | Personally, I'd have one thread that's responsible for reading values out of the device and storing the data in a data structure, and then a System.Windows.Forms.Timer (there's 3 Timers in .NET, this is the only one that ticks in the thread that's safe to update your controls) to read values out of that data structure and update the UI. You may need to synchronise that data structure, you may not.
That way the device can take as long as it likes to return data, or it can push as many millions of rows per second at you, and the UI thread will still poll at your predetermined tick rate (probably every 100 msec?). Since your timer ticks are just reading data out of memory, the UI won't block for IO. | 1 | 2 | 0 | I am new to the world of GUI programming and I am writing a little GUI app using IronPython and WinForms. It reads values from an external device and displays them in a ListView component (name, value). I want to periodically perform the reading and updating of the ListView component at a certain fixed rate.
I had the following ideas to accomplish this:
A timer, which periodically triggers the read/screen update directly in the OnTick handler
A timer, whose OnTick handler triggers a BackgroundWorker to perform the read/update
Since the first solution will block the GUI until the read/update loop is done, which, depending on the number of values being read from the device, could take some time, I think the BackgroundWorker might be a better solution. I might want to add some functionality to manipulate the ListView items later (add, remove values etc.) and a blocked GUI does not seem like a good idea.
Is there a certain design pattern or a better way to accomplish reading/updating screen data?
NOTE: Any code examples can be IronPython or C#. The conversion from C# to IronPython is pretty straight forward. Thanks! | Pattern for periodically updating screen data | 1.2 | 0 | 0 | 1,455 |
3,595,835 | 2010-08-29T17:38:00.000 | 1 | 1 | 0 | 0 | python,security,passwords,network-programming | 3,595,865 | 2 | true | 0 | 0 | The best way is to authenticate via SSL/TLS. The best way of storing passwords is to store them hashed with some complex hash like sha1(sha1(password)+salt) with salt. | 1 | 0 | 0 | I'm writing a game which requires users to log in to their accounts in order to be able to play. What's the best way of transmitting passwords from client to server and storing them?
I'm using Python and Twisted, if that's of any relevance. | Handling Password Authentication over a Network | 1.2 | 0 | 1 | 447 |
3,595,948 | 2010-08-29T18:07:00.000 | 1 | 0 | 1 | 0 | python,ruby,mongodb,nosql | 3,597,947 | 2 | false | 1 | 0 | Your idea is fundamentally correct. I mean, as long as the language can handle command-line interpretation and support a MongoDB driver, then you could theoretically build a new MongoDB shell.
However, I regularly read through the MongoDB mailing lists and I think that you're kind of on your own for this idea right now. Hey, writing a Ruby shell for Mongo would be an awesome way to learn a lot about Mongo. However, the current Mongo community is still relatively small and no one is really complaining too much about the javascript shell. | 1 | 1 | 0 | Or, does using Ruby's irb and then require 'mongo' and adding some Connect
statement essentially act like a Ruby shell... it would be great if a
Ruby shell can be possible which as convenient as the Javascript
Shell. | Does MongoDB have a Ruby Shell or Python Shell in addition to the Javascript shell? | 0.099668 | 0 | 0 | 472 |
3,596,485 | 2010-08-29T20:35:00.000 | 3 | 0 | 0 | 1 | python,file,cross-platform,disk | 3,596,681 | 4 | true | 0 | 0 | There isn't really a unified naming scheme for Linux devices that guarantees you a formatable block device. There are conventions, but they can vary widely and I can call my thumb-drive /Thomas/O if I want and there is no cross-platform way in Python to know:
That /Thomas/O corresponds to /dev/sdf1
That /dev/sdf1 can have a FAT32 filesystem made on it
That /dev/sdf is not preferred to /dev/sdf1
I'm pretty sure that neither is there a cross-platform Python module which will allow you to determine that H:/ is formattable on a Windows system but that Z:/ is not.
Each system will require its own specific checks and validations which you could best learn from studying open-source disk manipulation software. | 2 | 12 | 0 | I am using Python2.6. I am trying to list the disk drives that a system may have.
On Windows, it may be something like C:/, D:/, E:/, etc. On Linux, it may be something like /boot, /media/SDCard, etc. And I don't know what it's like on a Mac. Maybe something under /Volumes.
Does anyone know of a cross platform way (that is, one which works on Linux, Windows and Mac) in Python?
Thanks! | Cross platform way to list disk drives on Linux, Windows and Mac using Python? | 1.2 | 0 | 0 | 15,615 |
3,596,485 | 2010-08-29T20:35:00.000 | 2 | 0 | 0 | 1 | python,file,cross-platform,disk | 55,051,781 | 4 | false | 0 | 0 | I don't see a way in psutil to include net mounts on Windows. I.e., \foobar\home is mapped to X:, but X: does not appear in the list returned by psutil.disk_partitions() (local drives are).
Update: To include net drives in the returned list, simply use:
psutil.disk_partitions(all=True)
Works quite well. | 2 | 12 | 0 | I am using Python2.6. I am trying to list the disk drives that a system may have.
On Windows, it may be something like C:/, D:/, E:/, etc. On Linux, it may be something like /boot, /media/SDCard, etc. And I don't know what it's like on a Mac. Maybe something under /Volumes.
Does anyone know of a cross platform way (that is, one which works on Linux, Windows and Mac) in Python?
Thanks! | Cross platform way to list disk drives on Linux, Windows and Mac using Python? | 0.099668 | 0 | 0 | 15,615 |
3,597,143 | 2010-08-30T00:19:00.000 | 4 | 1 | 0 | 0 | python,web-applications | 3,597,157 | 4 | false | 1 | 0 | There are a few php style python options out there. Mod_python used to ship with one, and spyce had an alternate implementation, but that modality is out of favor with pythonistas. Instead, use a templating language. Genshi and jinja2 are both popular, but there are lots to choose from.
Since you are new to web programming with python, you would probably be best off choosing an entire framework get started. Django, turbogears, and cherrypy are a few to check out. These frameworks will all include all the tools you need to make a modern website, including a templating language. | 1 | 3 | 0 | I'm just starting out learning python (for webapp usage) but I'm confused as to the best way for using it with html files and dynamic data.
I know php has the <?php ?> tags which are great - does python have something like this or equivalent, if not how should I be doing it? | PHP style inline tags for Python? | 0.197375 | 0 | 0 | 1,597 |
3,597,332 | 2010-08-30T01:32:00.000 | 1 | 0 | 0 | 1 | python,django,google-app-engine,fixtures,django-fixtures | 3,605,268 | 1 | true | 1 | 0 | Turns out the issue was caused because I wasn't declaring my model correctly in models.py
When using google-app-engine-django, each model should be a subclass of:
appengine_django.db.BaseModel
after fixing this, it works. I also needed to put a valid pk: value in my fixture. | 1 | 1 | 0 | I'm having troubles loading fixtures on GAE with google-app-engine-django. I receive an error that says "DeserializationError: Invalid model identifier: 'fcl.User'"
./manage.py loaddata users
I'm trying to load a fixture that has the following data:
- model: fcl.User
fields:
firstname: test
lastname: testerson
email: test@example.com
user_id: '981167207188616462253'
status: active
usertype: player
creationtime: '2010-08-29 00:00:00'
do I need to do any other qualifying of my model name? The fixture lives at fcl/fixtures/users.yaml and model lives in at 'fcl/models.py'.
Any help would be greatly appreciated. | google-app-engine-django loading fixtures | 1.2 | 0 | 0 | 312 |
3,597,665 | 2010-08-30T03:21:00.000 | 3 | 0 | 0 | 0 | python,django,django-admin | 3,597,670 | 1 | true | 1 | 0 | It sounds like you associated .py files with Komodo Edit instead of with python.exe. The simplest workaround is to type "python django-admin.py ..." to execute the admin.
You can look in your Explorer options to change the association. There's a right-click menu option I think called "Open With..." that will let you change it. | 1 | 0 | 0 | I just went to create a new django project and I typed django-admin.py startproject my_project into the command prompt and it opened the django-admin.py file in my ide (komodo edit).
This happens every time I run this command in any form, even if I just try django-admin.py. Any ideas what's going on and how I fix it?
I'm on Win Xp with django 1.2.1 | django-admin.py launches IDE | 1.2 | 0 | 0 | 193 |
3,597,965 | 2010-08-30T04:58:00.000 | 4 | 0 | 0 | 1 | python,ubuntu,monitor,resolution | 3,598,627 | 6 | true | 0 | 0 | I assume you're a GUI toolkit. Why else would you be interested in the screen dimensions?
Check out gtk.gdk.screen_width() and gtk.gdk.screen_height() from PyGTK. Something similar should be available for QT. | 1 | 4 | 0 | Is there a equatable bit of code to GetSystemMetrics in win32api, for Ubuntu? I need to get the monitors width and height in pixels. | Getting Monitor resolution in Python on Ubuntu | 1.2 | 0 | 0 | 12,480 |
3,598,205 | 2010-08-30T06:03:00.000 | 2 | 0 | 1 | 0 | python,csv | 3,598,232 | 3 | false | 0 | 0 | Yes, you can compare values from any N sources. You have to extract the values from each and then compare them. If you make your question more specific (the format of the text file for instance), we might be able to help you more. | 3 | 0 | 0 | i have a csv file and a text file. is it possible to compare the values in both files? or should i have the values of both in a csv file to make it easier? | Is it possible to compare the values of a csv and text file in python? | 0.132549 | 0 | 0 | 525 |
3,598,205 | 2010-08-30T06:03:00.000 | 2 | 0 | 1 | 0 | python,csv | 3,598,241 | 3 | false | 0 | 0 | csv itself is of course text as well. And that's basically the problem when "comparing", there's no "text file standard". Even csv isn't that strictly defined, and there's no normal form. For exmaple, should a header be included? Is column ordering relevant?
How are fields separated in the textfile? Fixed width records? Newlines? Special markers (like csv)?
,
If you know the format of the textfile, you can read/parse it and compare the result with the csv file (which you will also need to read/parse of course), or generate csv from the textfile and compare that using diff. | 3 | 0 | 0 | i have a csv file and a text file. is it possible to compare the values in both files? or should i have the values of both in a csv file to make it easier? | Is it possible to compare the values of a csv and text file in python? | 0.132549 | 0 | 0 | 525 |
3,598,205 | 2010-08-30T06:03:00.000 | 3 | 0 | 1 | 0 | python,csv | 3,598,274 | 3 | false | 0 | 0 | is it possible to compare the values
in both files?
Yes. You can open them both in binary mode an compare the bytes, or in text mode and compare the characters. Neither will be particularly useful, though.
or should i have the values of both in
a csv file to make it easier?
Convert them both to list-of-lists format. For the CSV file, use a csv.reader. For the text file, use [line.split('\t') for line in open('filename.txt')] or whatever the equivalent is for your file format. | 3 | 0 | 0 | i have a csv file and a text file. is it possible to compare the values in both files? or should i have the values of both in a csv file to make it easier? | Is it possible to compare the values of a csv and text file in python? | 0.197375 | 0 | 0 | 525 |
3,599,213 | 2010-08-30T09:27:00.000 | 2 | 0 | 1 | 1 | python,windows,system,administration | 3,599,566 | 1 | false | 0 | 0 | Are you installing or uninstalling?
Installing:
Easy way: subprocess.Popen the installer.
Nearly-as-easy way: subprocess.Popen the installer, with some Windows hackery so that the user doesn't have to click anything.
Uninstalling:
As above.
Hard way: work out the files changed on the computer and revert them manually. | 1 | 0 | 0 | I would like to add add/programs like adobe acrobat reader and other application in windows XP using Python script. Kindly looking for some help.
Thanks in advance!
Everest. | Add/remove programs in Windows XP with Python script | 0.379949 | 0 | 0 | 2,948 |
3,599,569 | 2010-08-30T10:33:00.000 | 1 | 0 | 0 | 0 | java,python,xml,xsd | 3,599,767 | 3 | false | 1 | 0 | Funny, I'm concerning myself with something similar. I'm building an editor (not really WYSIWYG, but it abstracts the DOM away) for the XMLs Civilization 4 (strategy game) usesu to store about everything. I thought about it for quite a while and built two prototypes (in Python), one of which looks promising so I will extend it in the future. Note that Civ 4 XMLs are merely more than a buzzword-conform database (just the kind of data you better store in JSON/YAML and the like, mostly key-value pairs with a few sublists of key-value pairs - no recursive data structures).
My first approach was based on the fact that there are mostly key-value pairs, which doesn't fit documents that exploit the full power of XML (recursive data structures, etc). My new design is more sophisticated - up to now, I only built a (still buggy) validator factory this way, but I'm looking forward to extend it, e.g. for schema-sensetive editing widgets. The basic idea is to walk the XSD's DOM, recognize the expected content (a list of other nodes, text of a specific format, etc), build in turn (recursively) validators for these, and then build a higher-order validator that applies all the previously generated validators in the right order. It propably takes some exposure to functional programming to get comfortable with the idea. For the editing part (btw, I use PyQt), I plan to generate a Label-LineEdit pair for tags which contain text and a heading (Label) for tags that contain other elements, possibly indenting the subelements and/or providing folding. Again, recursion is the key to build these.
Qt allows us to attach a validator to an text input widget, so this part is easy once we can generate a validator for e.g. a tag containing an "int". For tags containing other tags, something similar to the above is possible: Generate a validator for each subelement and chain them. The only part that needs to change is how we get the content. Ignoring comments, attributes, processing instructions, etc, this should still be relatively simple - for a "tag: content" pair, generate "content" and feed it to your DOM parser; for elements with subelements, generate a representation of the children and put it between "...". Attributes could be implemented as key-value pairs too, only with an extra flag. | 1 | 4 | 0 | Is there any approach to generate editor of an XML file basing on an XSD scheme? (It should be a Java or Python web based editor). | Automatic editor of XML (based on XSD scheme) | 0.066568 | 0 | 1 | 4,417 |
3,599,800 | 2010-08-30T11:13:00.000 | 2 | 1 | 1 | 0 | silverlight,silverlight-4.0,ironpython,dynamic-language-runtime | 3,605,304 | 1 | true | 0 | 0 | I don't think there's a good way to do this other than pulling the elements of the date time out from properties like year, month, day, etc... and constructing a new DateTime instance from those. You could file feature request on ironpython.codeplex.com to have an explicit conversion to DateTime. That's pretty trivial to implement for at least some of these because they're using a DateTime behind the scenes. | 1 | 1 | 0 | I'm hosting an IronPython engine instance in my C# (Silverlight 4) app to execute some Python scripts on the fly. These scripts can return values of either IronPython.Modules.PythonDateTime+datetime, IronPython.Modules.PythonDateTime+date or IronPython.Modules.PythonDateTime+time types. I need to convert these to System.DateTime values in C# without losing resolution. How do I do this? | Type conversion from IronPython.Modules.PythonDateTime to System.DateTime | 1.2 | 0 | 0 | 334 |
3,600,101 | 2010-08-30T12:01:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 40,599,400 | 3 | false | 1 | 0 | You can pass parameters. Here is an example:
Let's say you have a main page and you want to POST to '/success'. Usually, you may use this way:
self.redirect('/sucess')
But if you want to pass some parameters from the main page to /success page, like username for example, you can modify the code to this:
self.redirect('/sucess?username=' + username)
In this way, you successfully passed the username value into the URL. In /success page, you can read and store the value by using this:
username = self.request.get('username')
At last, you can make you favorite information onto the /success page by using this simple code:
self.response.out.write('You\'ve succeeded, ' + username + '!')
But, it's of course not a safe way to pass password. I wish it helps. | 1 | 4 | 0 | In GAE (Python), using the webApp Framework, calling self.redirect('some_url') redirects the user to that URL via the GET method. Is it possible to do a (redirect) via the POST method with some parameters as well?
If possible, how?
Thanks! | Google App Engine self.redirect() POST method | 0 | 0 | 0 | 5,118 |
3,600,352 | 2010-08-30T12:38:00.000 | 1 | 0 | 1 | 0 | python,syntax,import | 3,600,396 | 8 | false | 0 | 0 | In fact, it's not that strange. Look at how we "import", "include" or "require" in other languages. We always specify the namespace first. include "inc/config.php" in PHP for example. So in a way, it keeps our usual way of including files or modules. | 3 | 17 | 0 | I always wondered why the syntax for importing specific objects from a module is from module import x, y, z instead of import x, y, z from module. I'm not a native speaker, but isn't the latter more correct/natural?
So, what is the reason to put the from first? Is it merely to simplify the grammar (require less lookahead)? Is it an attempt to make the two kinds of imports visually more distinct? Or is it one of these cases where the obvious way is "not obvious at first unless you're Dutch"? ;) | Reasoning behind `from ... import ...` syntax in Python | 0.024995 | 0 | 0 | 10,858 |
3,600,352 | 2010-08-30T12:38:00.000 | 5 | 0 | 1 | 0 | python,syntax,import | 3,600,407 | 8 | false | 0 | 0 | I don't know the complete heritage of this syntax, as it dates from Python 1.x days. But I find it useful to be able to scan down the left side of the source, and quickly find the module names that a script depends on. If a statement read "import a,b,c,d,e,really_long_name, alsdf,lsdf from blah", it would take me a while to find that this script depended on blah. | 3 | 17 | 0 | I always wondered why the syntax for importing specific objects from a module is from module import x, y, z instead of import x, y, z from module. I'm not a native speaker, but isn't the latter more correct/natural?
So, what is the reason to put the from first? Is it merely to simplify the grammar (require less lookahead)? Is it an attempt to make the two kinds of imports visually more distinct? Or is it one of these cases where the obvious way is "not obvious at first unless you're Dutch"? ;) | Reasoning behind `from ... import ...` syntax in Python | 0.124353 | 0 | 0 | 10,858 |
3,600,352 | 2010-08-30T12:38:00.000 | 1 | 0 | 1 | 0 | python,syntax,import | 3,600,427 | 8 | false | 0 | 0 | It might make more sense in english to say import x, y, z from module but in programming it makes much more sense to bring the more general Item first and then bring the details.
It might not be the reason but it makes things easier for the compiler or interpreter.
Try writing a compiler and you'll know what I mean :D | 3 | 17 | 0 | I always wondered why the syntax for importing specific objects from a module is from module import x, y, z instead of import x, y, z from module. I'm not a native speaker, but isn't the latter more correct/natural?
So, what is the reason to put the from first? Is it merely to simplify the grammar (require less lookahead)? Is it an attempt to make the two kinds of imports visually more distinct? Or is it one of these cases where the obvious way is "not obvious at first unless you're Dutch"? ;) | Reasoning behind `from ... import ...` syntax in Python | 0.024995 | 0 | 0 | 10,858 |
3,602,645 | 2010-08-30T17:15:00.000 | 2 | 0 | 0 | 0 | python,google-app-engine,qr-code | 3,602,758 | 4 | true | 0 | 1 | I've looked before with no success. Two problems are that native c code can't be compiled and you can't get access to the file system.
pyqrcode didn't work out and neither did zxing. | 1 | 4 | 0 | I was wondering if there is a good library for python for decoding QR code. Basically what I would like is to give library image with QR code on it and the library would output contents saved in image. | Google app engine QR code decoder | 1.2 | 0 | 0 | 3,926 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.