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,481,554 | 2010-08-14T01:00:00.000 | 0 | 0 | 1 | 0 | python,operators | 3,481,558 | 5 | false | 0 | 0 | It just personal preference. You could also compare if x != 3 and if not x == 3. There's no difference between the two expressions you've shown. | 2 | 67 | 0 | I've noticed that both of these work the same:
if x not in list and if not x in list.
Is there some sort of difference between the two in certain cases? Is there a reason for having both, or is it just because it's more natural for some people to write one or the other?
Which one am I more likely to see in other people's code? | "x not in" vs. "not x in" | 0 | 0 | 0 | 32,712 |
3,481,554 | 2010-08-14T01:00:00.000 | 3 | 0 | 1 | 0 | python,operators | 3,481,565 | 5 | false | 0 | 0 | not x in L isn't explicitly disallowed because that would be silly. x not in L is explicitly allowed (though it compiles to the same bytecode) because it's more readable.
x not in L is what everyone uses, though. | 2 | 67 | 0 | I've noticed that both of these work the same:
if x not in list and if not x in list.
Is there some sort of difference between the two in certain cases? Is there a reason for having both, or is it just because it's more natural for some people to write one or the other?
Which one am I more likely to see in other people's code? | "x not in" vs. "not x in" | 0.119427 | 0 | 0 | 32,712 |
3,481,949 | 2010-08-14T04:01:00.000 | 2 | 1 | 1 | 0 | python,komodo,komodoedit | 3,482,353 | 1 | true | 0 | 0 | Problem solved itself when I closed Komodo, saving the project, and reopened it.
Sounds like Komodo's internal representation was out-of-date or corrupted.
I'll leave the question here for the next person who stumbles over it. | 1 | 2 | 0 | I am using Komodo edit on a Python file on Windows.
When I type import s it successfully lists all the importable files starting with s, including one of my modules in one of my directories.
When I type import t it lists all the importable files starting with t, EXCLUDING one of my modules in the same directory.
Even though Komodo can't find it, the Python interpreter finds and runs both files fine. It is purely a problem with Komodo's Code Intelligence.
The name of the missing module is 9 lower-case letters (nothing fancy). It doesn't clash with any other modules. It is in the same directory as the module that can be found.
Any suggestions about why one module is found and another isn't? | Komodo Edit auto-complete won't find a Python module | 1.2 | 0 | 0 | 1,865 |
3,482,112 | 2010-08-14T05:13:00.000 | 1 | 0 | 1 | 0 | python,event-handling,wxpython | 3,482,120 | 3 | false | 0 | 0 | If communicating by stdin/stdout is what you need, you should use the subprocess module. | 1 | 3 | 0 | I'm working on one GUI program, and was gonna add a long running task into one event, but I found this would make the whole program freeze a lot, so considering other people's advice I would make the GUI only responsible for starting, stopping and monitoring and make the long running task run as a separate script. The only way I know to run another script in one script is by import, is there any other methods to communicate with another script, I mean such as reading another's stdout and terminating it at any time you want? | How to control/call another python script within one python script? (Communicate between scripts) | 0.066568 | 0 | 0 | 2,081 |
3,482,152 | 2010-08-14T05:27:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,redirect | 3,483,631 | 2 | false | 1 | 0 | You need to use a third-party site to do the redirection to www.*; many registrars offer this service. Godaddy's service (which is even free with domain registration) forwards foo.com/bar to www.foo.com/bar; I can't speak to the capabilities of the others but it seems to me that any one that doesn't behave this way is broken. | 1 | 4 | 0 | I'm working on a site, colorurl.com, and I need users to be able to type in colorurl.com/00ff00 (or some variation of that), and see the correct page. However, with the naked domain issue, users who type in colorurl.com/somepath will instead be redirected to www.colorurl.com/.
Is there a way to detect this in python, and then redirect the user to where they meant to go (With the www. added?)
EDIT:
Clarification: In my webhost's configuration I have colorurl.com forward to www.colorurl.com. They do not support keeping the path (1and1). I have to detect the previous path and redirect users to it.
User goes to colorurl.com/path
User is redirected to www.colorurl.com
App needs to detect what the path was.
App sends user to www.colorurl.com/path | Google App Engine - Naked Domain Path Redirect in Python | 0 | 0 | 1 | 830 |
3,482,622 | 2010-08-14T08:38:00.000 | 5 | 1 | 0 | 1 | python,ide,autocomplete,duck-typing,built-in | 9,430,038 | 7 | false | 0 | 0 | Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead) | 1 | 5 | 0 | I'm new to Python, with a background in statically typed languages including lots and lots of Java.
I decided on PyDev in eclipse as an IDE after checking features/popularity etc.
I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after:
datafile = open(directory+"/"+account, 'r')
datafile.
No useful methods are suggested (e.g. realines). Only things like call.
I am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'.
Is it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration!
Thanks, | Autocompletion in dynamic language IDEs, specifically Python in PyDev | 0.141893 | 0 | 0 | 3,018 |
3,483,179 | 2010-08-14T12:03:00.000 | 1 | 0 | 0 | 0 | python,listbox,wxpython,center,alignment | 3,506,756 | 1 | true | 0 | 1 | No, the default ListBox won't work for that. Try the VListBox instead. | 1 | 0 | 0 | I want the text of the ListBox to be centered, is that possible? | How to align the text in a wx.ListBox using wxPython? | 1.2 | 0 | 0 | 434 |
3,483,492 | 2010-08-14T13:25:00.000 | 2 | 0 | 0 | 0 | ironpython,pyqt | 3,490,601 | 3 | false | 0 | 1 | Hope someone else who spent more time messing around with this comes by and gives you qualified, ambiguous answer, but here is some questionable insight from my personal experience:
PyQt relates to cPython in a way that is very different than .Net relates to IronPython.
While IronPython is built on TOP of .Net, PyQt is a BINARY, semi-automatically generated set of bindings specific to a version of cPython against which it was compiled.
For a variety of reasons, i have problems running "standard" BINARY python modules against IronPython. Only the pure-Python modules that can be interpreted by IronPython as "Python" would ever work for me.
I am not saying "it can't be done," but I do expect you to have very bad experience with the set up if you manage to compile and install PyQt into IronPython. | 1 | 2 | 0 | Is it possible to use PyQt from IronPython?
From what I've read IronPython should work with CPython compatible libraries but out of the box it doesn't seem to work.
If it is possible, will code completion work? | Using PyQt from IronPython | 0.132549 | 0 | 0 | 2,411 |
3,483,520 | 2010-08-14T13:32:00.000 | 9 | 0 | 1 | 0 | python,dictionary,setdefault | 6,287,888 | 18 | false | 0 | 0 | As Muhammad said, there are situations in which you only sometimes wish to set a default value. A great example of this is a data structure which is first populated, then queried.
Consider a trie. When adding a word, if a subnode is needed but not present, it must be created to extend the trie. When querying for the presence of a word, a missing subnode indicates that the word is not present and it should not be created.
A defaultdict cannot do this. Instead, a regular dict with the get and setdefault methods must be used. | 2 | 217 | 0 | The addition of collections.defaultdict in Python 2.5 greatly reduced the need for dict's setdefault method. This question is for our collective education:
What is setdefault still useful for, today in Python 2.6/2.7?
What popular use cases of setdefault were superseded with collections.defaultdict? | Use cases for the 'setdefault' dict method | 1 | 0 | 0 | 117,147 |
3,483,520 | 2010-08-14T13:32:00.000 | 3 | 0 | 1 | 0 | python,dictionary,setdefault | 40,944,406 | 18 | false | 0 | 0 | One drawback of defaultdict over dict (dict.setdefault) is that a defaultdict object creates a new item EVERYTIME non existing key is given (eg with ==, print). Also the defaultdict class is generally way less common then the dict class, its more difficult to serialize it IME.
P.S. IMO functions|methods not meant to mutate an object, should not mutate an object. | 2 | 217 | 0 | The addition of collections.defaultdict in Python 2.5 greatly reduced the need for dict's setdefault method. This question is for our collective education:
What is setdefault still useful for, today in Python 2.6/2.7?
What popular use cases of setdefault were superseded with collections.defaultdict? | Use cases for the 'setdefault' dict method | 0.033321 | 0 | 0 | 117,147 |
3,483,675 | 2010-08-14T14:11:00.000 | 0 | 0 | 0 | 0 | python,event-handling,wxpython | 41,389,878 | 2 | false | 0 | 1 | In the __init__( ) for your main frame put this:
wx.CallAfter( func_name ) | 2 | 0 | 0 | I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being "clicked" once the program starts, how do I do it? | How to make a event run immediately after a GUI program starts in wxpython? | 0 | 0 | 0 | 205 |
3,483,675 | 2010-08-14T14:11:00.000 | 1 | 0 | 0 | 0 | python,event-handling,wxpython | 3,483,688 | 2 | true | 0 | 1 | In the main frame constructor set a one-shot timer with interval 0 that fires the event. | 2 | 0 | 0 | I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being "clicked" once the program starts, how do I do it? | How to make a event run immediately after a GUI program starts in wxpython? | 1.2 | 0 | 0 | 205 |
3,483,723 | 2010-08-14T14:24:00.000 | 0 | 0 | 1 | 0 | python,macos | 69,496,412 | 5 | false | 0 | 0 | The command
brew install readline
worked for me. | 2 | 27 | 0 | I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing?
When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys.
I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone know a way to fix this?
Many thanks,
G | Python interactive mode history and arrow keys | 0 | 0 | 0 | 10,940 |
3,483,723 | 2010-08-14T14:24:00.000 | 15 | 0 | 1 | 0 | python,macos | 26,222,005 | 5 | false | 0 | 0 | If you are using homebrew, this is an easy fix:
brew uninstall python
brew uninstall readline
brew install readline --universal
brew install python
That fixed it for me (running OS X Mavericks 10.9.5) | 2 | 27 | 0 | I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing?
When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys.
I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone know a way to fix this?
Many thanks,
G | Python interactive mode history and arrow keys | 1 | 0 | 0 | 10,940 |
3,484,232 | 2010-08-14T16:47:00.000 | 7 | 1 | 0 | 0 | c#,powershell,ironpython,ironruby,dynamic-language-runtime | 3,484,368 | 3 | false | 0 | 0 | number 2 is true (the dynamic lang teams have been losing headcount for awhile now) and an excellent reason. Ruby and Python aren't MS languages, and as such Iron * is just 'get it working on .NET'. PowerShell is a Microsoft creation, Microsoft-controlled, and Microsoft-supported.
More importantly, multiple Microsoft products have taken deep dependencies on PowerShell (Exchange, SharePoint, etc.) so there's very little question of PowerShell's ongoing support as a language.
Last, PowerShell considers being the scripting lang for other applications as one of its first-class support targets. | 3 | 12 | 0 | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):
1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable.
2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?
As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.
Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP? | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? | 1 | 0 | 0 | 3,780 |
3,484,232 | 2010-08-14T16:47:00.000 | 12 | 1 | 0 | 0 | c#,powershell,ironpython,ironruby,dynamic-language-runtime | 3,496,609 | 3 | false | 0 | 0 | I'm not convinced PowerShell has "being a scripting language for applications" anywhere in it's long-term goals. It's first a shell, second an integration & automation engine, and third a shell scripting language ... since it's not redistributable at all, I'm not sure where embedded scripting fits in.
It's certainly very easy to host PowerShell -- assuming that it's pre-installed on your target PCs-- so it's a very viable option, but I think that in general it's just as easy to do it with IronRuby or IronPython.
I doubt the DLR itself is going away, so I think using a DLR language is still a good choice for this: you'd be set up to accept other DLR languages with much less effort, and the DLR and languages are redistributable.
Also, the work to host PowerShell only gets you PowerShell -- whereas you can leverage the same work to get IronPython and IronRuby working. Who knows, since PowerShell is a dynamic language, maybe it will be ported to the DLR with proper dynamics support in a future version ... but it's unlikely to ever be redistributable, because Microsoft doesn't consider it a dev tool, but rather a core part of the OS.
Bottom line: using the DLR is much more portable -- and not just to XP but even to Mono (and thus to Linux, OS X, iOS, Android, etc... and even to the web or Windows Phone via Silverlight). | 3 | 12 | 0 | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):
1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable.
2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?
As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.
Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP? | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? | 1 | 0 | 0 | 3,780 |
3,484,232 | 2010-08-14T16:47:00.000 | 2 | 1 | 0 | 0 | c#,powershell,ironpython,ironruby,dynamic-language-runtime | 3,504,982 | 3 | false | 0 | 0 | I'm in a similar position. I decided to use IronPython scripting but ever since I saw Anders Hejlsberg's talk "The Future of C#", I've had a feeling IronPython was doomed.
It was in Microsoft's interest to get the DLR developed but they ultimately want us to use tools and languages they control. After all, aren't you using C# and not Java? So what will a Microsoft dynamic language look like? How about dynamic, interpreted C# (Iron C#)? Hejlsberg's talk made it clear it isn't that far away. He even had a console window with a REPL interface. That said, there's always a possibility for Iron VB. Talk about closing the loop.
On the plus side for us programmers, Iron C# also solves another problem that I'm having trouble with -- the existence of two parallel object environments, one of .Net objects, one of Python objects. It takes work to get from one to the other. I assume an Iron C# would utilize the .Net class structure.
My advice: Stick with Iron Python and .Net classes. When Iron VB or Iron C# happens, it'll be a quick, maybe automatic, language translation. Besides, if enough of us use IronPython, Microsoft may change their mindset. | 3 | 12 | 0 | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!):
1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable.
2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution?
As this is my first time adding scripting to an application though, I'd welcome all the advice I can get from people who have been down this road before.
Specifically, besides letting me know whether you agree with my two points above, I'd like to know if IronRuby and IronPython are much easier to use (for a user, not developer) than powershell, and if in your experience using the DLR is as easy as just passing an object to a powershell runspace? And if I added support for the DLR and IR/IP scripting would my application still be backwards compatible with XP? | Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? | 0.132549 | 0 | 0 | 3,780 |
3,485,203 | 2010-08-14T21:34:00.000 | 0 | 0 | 0 | 0 | python,networking,snmp | 3,486,005 | 3 | false | 0 | 0 | You might try running nmap against the ports you want to check, but that won't necessarily give you an indication that the server process on the other side of an open port is alive. | 2 | 3 | 0 | Is there a way to monitor server ports using SNMP (I'm using net-snmp-python to check this with python).
So far I've checked pretty simple with "nc" command, however I want to see if I can do this with SNMP.
Thank you for your answers and patience. | Check ports with SNMP (net-snmp) | 0 | 0 | 1 | 9,078 |
3,485,203 | 2010-08-14T21:34:00.000 | 0 | 0 | 0 | 0 | python,networking,snmp | 3,485,524 | 3 | false | 0 | 0 | It's hard to see where SNMP might fit in.
The best way to monitor would be to use a protocol specific client (i.e., run a simple query v.s. MySQL, retrieve a test file using FTP, etc.)
If that doesn't work, you can open a TCP or UDP socket to the ports and see if anyone is listening. | 2 | 3 | 0 | Is there a way to monitor server ports using SNMP (I'm using net-snmp-python to check this with python).
So far I've checked pretty simple with "nc" command, however I want to see if I can do this with SNMP.
Thank you for your answers and patience. | Check ports with SNMP (net-snmp) | 0 | 0 | 1 | 9,078 |
3,485,369 | 2010-08-14T22:28:00.000 | 3 | 0 | 0 | 0 | python,django,django-admin | 3,485,462 | 3 | true | 1 | 0 | Stripping the junk and such should be done with a custom formfield.
Downloading the images... there are multiple ways to fix that problem.
If you choose to store the image location and original location in the database, than you should do it with a pre-save signal.
If you choose to store the images locally directly, than you can make it part of the formfield aswell. Simply download all remote images and replace the urls with a local url. | 1 | 3 | 0 | I have a Django model with a text field. I'm using a rich text editor (nicEdit) on the admin site to allow the client to easily enter markup into the field. I'd like to process the contents of the field and perform a few actions before anything is inserted into the database.
For example, I want to strip junk generated by MS Word, font tags, etc. I hope this part should be easy, but I'm not sure what to override or hook to get this working.
I also want to detect remotely-linked images, download a local copy to MEDIA_ROOT, and relink the img src to the local image. I'm not quite sure how to go about fetching the remote image; I thought django.Storage might help but it looks like it's unable to fetch content from a remote URL.
Any suggestions? | Process field before database insert / update | 1.2 | 0 | 0 | 2,000 |
3,486,372 | 2010-08-15T05:49:00.000 | 1 | 0 | 1 | 0 | python,http | 3,486,383 | 3 | false | 0 | 0 | You are going to have to implement that asynchronously as HTTP protocol states you have a request and a reply.
Another option would be to work directly with the socket, bypassing any pre-built module. This would allow you to violate protocol and write your own bit that ignores any responses, in essence dropping the connection after it has made the request. | 2 | 6 | 0 | I want to send it and forget it. The http rest service call I'm making takes a few seconds to respond. The goal is to avoid waiting those few seconds before more code can execute.
I'd rather not use python threads
I'll use twisted async calls if I must and ignore the response. | How can I make an http request without getting back an http response in Python? | 0.066568 | 0 | 1 | 2,585 |
3,486,372 | 2010-08-15T05:49:00.000 | 0 | 0 | 1 | 0 | python,http | 3,486,378 | 3 | false | 0 | 0 | HTTP implies a request and a reply for that request. Go with an async approach. | 2 | 6 | 0 | I want to send it and forget it. The http rest service call I'm making takes a few seconds to respond. The goal is to avoid waiting those few seconds before more code can execute.
I'd rather not use python threads
I'll use twisted async calls if I must and ignore the response. | How can I make an http request without getting back an http response in Python? | 0 | 0 | 1 | 2,585 |
3,486,384 | 2010-08-15T05:54:00.000 | 3 | 0 | 1 | 0 | python | 46,546,045 | 8 | false | 0 | 0 | Most of previous examples will raise an exception in case your string is not long enough.
Another approach is to use
'yourstring'.ljust(100)[:100].strip().
This will give you first 100 chars.
You might get a shorter string in case your string last chars are spaces. | 1 | 121 | 0 | Can seem to find a substring function in python.
Say I want to output the first 100 characters in a string, how can I do this?
I want to do it safely also, meaning if the string is 50 characters it shouldn't fail. | Output first 100 characters in a string | 0.07486 | 0 | 0 | 174,305 |
3,486,708 | 2010-08-15T08:28:00.000 | 0 | 0 | 0 | 1 | bash,shell,wxpython | 3,506,700 | 2 | false | 0 | 0 | Maybe pyCrust plus the Python debugger? | 1 | 0 | 0 | Hey I want to create a bash-shell in wxPython, the only thing it should be able to do is run a python file and be able to offer user_input on the fly.
(I know there is a Python Shell, but that is something different)
Can someone help me with this? thanks in advance | wxPython -- Bash shell | 0 | 0 | 0 | 330 |
3,487,447 | 2010-08-15T12:59:00.000 | 0 | 1 | 0 | 0 | python,scripting,sms,libgmail | 3,487,491 | 1 | true | 0 | 0 | As far as I know libgmail is not compatible with the current Gmail interface. If I am not mistaken libgmail is not actively maintained either. You might want to look at alternative options. | 1 | 1 | 0 | i'm new to python , and trying to write a script in order to send SMS's ,
after quick googling i found this lib: libgmail, and successfully installed it ,
this is the code i use to send SMS:
!/usr/bin/env python
import libgmail
ga = libgmail.GmailAccount("username@gmail.com", "password")
myCellEmail = "phonenumber@message.carrier.end"
ga.login()
msg=libgmail.GmailComposedMessage(myCellEmail, "", "Hello World! From python-libgmail!")
ga.sendMessage(msg)
i get the following error when trying to run it:
Traceback (most recent call last):
File "C:\Users\Amit\Desktop\SMS\sms.py", line 14, in
ga.login()
File "C:\Python27\lib\site-packages\libgmail.py", line 305, in login
pageData = self._retrievePage(req)
File "C:\Python27\lib\site-packages\libgmail.py", line 340, in _retrievePage
req = ClientCookie.Request(urlOrRequest)
File "build\bdist.win32\egg\mechanize_request.py", line 31, in init
File "build\bdist.win32\egg\mechanize_rfc3986.py", line 62, in is_clean_uri
TypeError: expected string or buffer
if you have any ideas , please share ..
thanks a lot
amitos80 | cant send SMS vla libgmail - python | 1.2 | 0 | 0 | 571 |
3,487,456 | 2010-08-15T13:00:00.000 | 10 | 0 | 0 | 0 | python,sqlite,mongodb | 3,491,117 | 5 | false | 0 | 0 | As others have said, MongoDB does not have single-server durability right now. Fortunately, it's dead easy to set up multi-node replication. You can even set up a second machine in another data center and have data automatically replicated to it live!
If a write must succeed, you can cause Mongo to not return from an insert/update until that data has been replicated to n slaves. This ensures that you have at least n copies of the data. Replica sets allow you to add and remove nodes from your cluster on the fly without any significant work; just add a new node and it'll automatically sync a copy of the data. Remove a node and the cluster rebalances itself. It is very much designed to be used across multiple machines, with multiple nodes acting in parallel; this is it's preferred default setup, compared to something like MySQL, which expects one giant machine to do its work on, which you can then pair slaves against when you need to scale out. It's a different approach to data storage and scaling, but a very comfortable one if you take the time to understand its difference in assumptions, and how to build an architecture that capitalizes on its strengths. | 3 | 12 | 0 | I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases.
I've never worked with Mongo in the past, no would have to learn from scratch (will be working in python). After googling around a bit, I came across a number of somewhat horrific stories about Mongodb re. reliability. Is this still a major problem ? In a crunch, I will of course retain the sqlite backups, but I'd rather not have to reconstruct my mongo databases constantly.
Just wondering what sort data corruption issues people have actually faced recently with Mongo ? Is this a big concern?
Thanks! | Mongodb - are reliability issues significant still? | 1 | 1 | 0 | 3,302 |
3,487,456 | 2010-08-15T13:00:00.000 | 3 | 0 | 0 | 0 | python,sqlite,mongodb | 3,488,244 | 5 | false | 0 | 0 | Mongo does not have ACID properties, specifically durability. So you can face issues if the process does not shut down cleanly or the machine loses power. You are supposed to implement backups and redundancy to handle that. | 3 | 12 | 0 | I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases.
I've never worked with Mongo in the past, no would have to learn from scratch (will be working in python). After googling around a bit, I came across a number of somewhat horrific stories about Mongodb re. reliability. Is this still a major problem ? In a crunch, I will of course retain the sqlite backups, but I'd rather not have to reconstruct my mongo databases constantly.
Just wondering what sort data corruption issues people have actually faced recently with Mongo ? Is this a big concern?
Thanks! | Mongodb - are reliability issues significant still? | 0.119427 | 1 | 0 | 3,302 |
3,487,456 | 2010-08-15T13:00:00.000 | 2 | 0 | 0 | 0 | python,sqlite,mongodb | 3,490,547 | 5 | false | 0 | 0 | I don't see the problem if you have the same data also in the sqlite backups. You can always refill your MongoDb databases. Refilling will only take a few minutes. | 3 | 12 | 0 | I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases.
I've never worked with Mongo in the past, no would have to learn from scratch (will be working in python). After googling around a bit, I came across a number of somewhat horrific stories about Mongodb re. reliability. Is this still a major problem ? In a crunch, I will of course retain the sqlite backups, but I'd rather not have to reconstruct my mongo databases constantly.
Just wondering what sort data corruption issues people have actually faced recently with Mongo ? Is this a big concern?
Thanks! | Mongodb - are reliability issues significant still? | 0.07983 | 1 | 0 | 3,302 |
3,487,507 | 2010-08-15T13:16:00.000 | 0 | 1 | 1 | 0 | python,unit-testing,readability | 3,488,720 | 3 | false | 0 | 0 | It feels like there maybe some room for breaking your method into smaller pieces. Ones focused on dealing with parsing input and formatting output, could be separate from the actual clustering logic. This way tests around your clustering methods would be fewer and dealing with easily understood and testable data structures like dicts and lists. | 2 | 4 | 0 | I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things:
Does each cluster contain the correct elements (and maybe other properties as well)?
Does each cluster point to the correct children?
Does each cluster point to the correct parent?
I have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data.
Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions? | Writing unittests for a function that returns a hierarchy of objects | 0 | 0 | 0 | 72 |
3,487,507 | 2010-08-15T13:16:00.000 | 2 | 1 | 1 | 0 | python,unit-testing,readability | 3,487,617 | 3 | true | 0 | 0 | If there are isomorphic results, you should probably have a predicate that can test for logical equivalence. This would likely be good for your code unit as well as helping to implement the unit test.
This is the core of Manoj Govindan's answer without the string intermediates and since you aren't interested in string intermediates (presumably) then adding them to the test regime would be an unnecessary source of error.
As to the readability issue, you'd need to show what you consider unreadable for a proper answer to be given. Perhaps the equivalence predicate will obviate this. | 2 | 4 | 0 | I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things:
Does each cluster contain the correct elements (and maybe other properties as well)?
Does each cluster point to the correct children?
Does each cluster point to the correct parent?
I have two problems here. First, how do I specify the expected output in a readable format. Second, how do I write a test-assertion accepts isomorphic variants of the expected data I provide? Suppose one cluster in the expected hierarchy has two children, A and B. Now suppose that cluster is represented by an object with the properties child1 and child2. I do not care whether child1 corresponds to cluster A or B, just that it corresponds to one of them, and that child2 corresponds to the other. The solution should be somewhat general because I will write several tests with different input data.
Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions? | Writing unittests for a function that returns a hierarchy of objects | 1.2 | 0 | 0 | 72 |
3,488,256 | 2010-08-15T16:41:00.000 | 2 | 0 | 1 | 0 | python,windows-7,python-idle | 16,830,685 | 10 | false | 0 | 0 | I ran into this weird situation also, and did a bit of troubleshooting. As a rigorous task, uninstalling, and re-installing the versions of python(2.6, 2.7, 3.1) and all my associated extensions and other site packages: in addition to the subsequent options that others have provided, that may have, or may not have, helped fix issues with the IDLE working properly. I found and error on my part, installing a 32 bit .msi on a 64 bit system causes a runtime .dll error with tkinter and therfore, causes IDLE to not start up properly, or not at all. Be mindful, and don't be a blind bat like me... :) | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 0.039979 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 10 | 0 | 1 | 0 | python,windows-7,python-idle | 29,646,059 | 10 | false | 0 | 0 | I got the same problem on window 10. Steps to solve the problem:
Locate the .idlerc folder in your profile directory (e.g. C:\Users\{your-username} without the braces).
Delete the .idlerc directory.
It worked for me... | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 1 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 6 | 0 | 1 | 0 | python,windows-7,python-idle | 10,644,585 | 10 | false | 0 | 0 | I too faced the same problem. But at last solved like this -->
Run Python\Lib\idlelib\idle.py as admin, i got the error that the file "recent-files.lst" can't be opened.
So go to your home folder, show hidden files, click on .idlerc and delete the file named "recent-files". Now IDLE is working... | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 1 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 0 | 0 | 1 | 0 | python,windows-7,python-idle | 27,628,227 | 10 | false | 0 | 0 | Run python setup program, change python 2x, choose to entirely remove tcl/tk, proceed, then run setup again, change python again, on the tcl\tk choose entire feature will be installed, proceed.
It worked for me. | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 0 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 0 | 0 | 1 | 0 | python,windows-7,python-idle | 40,044,077 | 10 | false | 0 | 0 | Even I was facing same issue with my code, But It is resolved now.
I was using 2.6 which was having old version of Xlrd, so I updated xlrd in 2.7 using pip and I opened my file with 2.7 and it works. | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 0 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 1 | 0 | 1 | 0 | python,windows-7,python-idle | 35,168,182 | 10 | false | 0 | 0 | Once I copied the C:\Python27\tcl\tcl8.5 folder to C:\Python27\Lib as suggested in Bogdan's answer the error message "This probably means that Tcl wasn't installed properly" went away. Instead I started seeing "This probably means that tk wasn't installed properly". I had to copy the C:\Python27\tcl\tk8.5 folder to C:\Python27\Lib as well. Once I did that running idle.py from the command line in C:\Python27\Lib\idlelib was error-free. | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 0.019997 | 0 | 0 | 62,164 |
3,488,256 | 2010-08-15T16:41:00.000 | 0 | 0 | 1 | 0 | python,windows-7,python-idle | 52,254,251 | 10 | false | 0 | 0 | Delete the .idlerc directory as suggested above, run the python installer again and choose repair. If needed associate the .py files with the python.exe executable in Python27 folder. This worked for me after removing python 3.7. | 7 | 7 | 0 | I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1.
Right now Idle cannot launch. What should i do to get it running?
NOTE:
I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py
i uninstalled 3.1 and installed back 2.7, not working neither... | Python IDLE is not starting on Windows 7 | 0 | 0 | 0 | 62,164 |
3,488,548 | 2010-08-15T18:00:00.000 | 0 | 0 | 1 | 0 | python,module,directory,importerror | 20,068,252 | 5 | false | 0 | 0 | Where are you storing the module you created? When I create a module, I do the following:
Create a folder in the lib\sitepackages folder in your python folder ex: myModules
Save a blank python file named init.py in this folder. The file does not have to contain any syntax. Later on, you can set module requirements in this file if you wish.
Save your module into this folder ex: myGamesModule.py
In idle (or whichever python connected IDE you use) type:
from myModules import myGamesModule
or
from myModules import myGamesModule as myGmMod
That should import your module and then you can call the classes etc
ex myGmMod.Player()
I am sure that this is correct, as I have just done it and it was ok. | 2 | 4 | 0 | I run Windows 7, and I can import built-in modules, but when I save my own script and try to import it in IDLE, I get an error saying that the module doesn't exist.
I use the Python text editor found by clicking "File" and "New Window" from the Python Shell. I save it as a .py file within a Module folder I created within the Python directory. However, whenever i type import module_name in IDLE, it says that the module doesn't exist.
What am I doing wrong, or not doing? I've tried import module_name, import module_name.py, python module_name, python module_name.py | Python Module Importing Issues | 0 | 0 | 0 | 18,759 |
3,488,548 | 2010-08-15T18:00:00.000 | 4 | 0 | 1 | 0 | python,module,directory,importerror | 3,488,565 | 5 | true | 0 | 0 | Python uses PYTHONPATH environment variable to define a list of folders which should be looked at when importing modules. Most likely your folder is not PYTHONPATH | 2 | 4 | 0 | I run Windows 7, and I can import built-in modules, but when I save my own script and try to import it in IDLE, I get an error saying that the module doesn't exist.
I use the Python text editor found by clicking "File" and "New Window" from the Python Shell. I save it as a .py file within a Module folder I created within the Python directory. However, whenever i type import module_name in IDLE, it says that the module doesn't exist.
What am I doing wrong, or not doing? I've tried import module_name, import module_name.py, python module_name, python module_name.py | Python Module Importing Issues | 1.2 | 0 | 0 | 18,759 |
3,489,071 | 2010-08-15T20:22:00.000 | 1 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 59,817,607 | 13 | false | 0 | 0 | Dictionary: A python dictionary is used like a hash table with key as index and object as value.
List: A list is used for holding objects in an array indexed by position of that object in the array.
Set: A set is a collection with functions that can tell if an object is present or not present in the set. | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 0.015383 | 0 | 0 | 207,368 |
3,489,071 | 2010-08-15T20:22:00.000 | 1 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 44,613,023 | 13 | false | 0 | 0 | Lists are what they seem - a list of values. Each one of them is numbered, starting from zero - the first one is numbered zero, the second 1, the third 2, etc. You can remove values from the list, and add new values to the end. Example: Your many cats' names.
Tuples are just like lists, but you can't change their values. The values that you give it first up, are the values that you are stuck with for the rest of the program. Again, each value is numbered starting from zero, for easy reference. Example: the names of the months of the year.
Dictionaries are similar to what their name suggests - a dictionary. In a dictionary, you have an 'index' of words, and for each of them a definition. In python, the word is called a 'key', and the definition a 'value'. The values in a dictionary aren't numbered - tare similar to what their name suggests - a dictionary. In a dictionary, you have an 'index' of words, and for each of them a definition. In python, the word is called a 'key', and the definition a 'value'. The values in a dictionary aren't numbered - they aren't in any specific order, either - the key does the same thing. You can add, remove, and modify the values in dictionaries. Example: telephone book. | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 0.015383 | 0 | 0 | 207,368 |
3,489,071 | 2010-08-15T20:22:00.000 | 634 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 3,489,100 | 13 | true | 0 | 0 | A list keeps order, dict and set don't: when you care about order, therefore, you must use list (if your choice of containers is limited to these three, of course ;-) ).
dict associates each key with a value, while list and set just contain values: very different use cases, obviously.
set requires items to be hashable, list doesn't: if you have non-hashable items, therefore, you cannot use set and must instead use list.
set forbids duplicates, list does not: also a crucial distinction. (A "multiset", which maps duplicates into a different count for items present more than once, can be found in collections.Counter -- you could build one as a dict, if for some weird reason you couldn't import collections, or, in pre-2.7 Python as a collections.defaultdict(int), using the items as keys and the associated value as the count).
Checking for membership of a value in a set (or dict, for keys) is blazingly fast (taking about a constant, short time), while in a list it takes time proportional to the list's length in the average and worst cases. So, if you have hashable items, don't care either way about order or duplicates, and want speedy membership checking, set is better than list. | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 1.2 | 0 | 0 | 207,368 |
3,489,071 | 2010-08-15T20:22:00.000 | 201 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 3,489,078 | 13 | false | 0 | 0 | Do you just need an ordered sequence of items? Go for a list.
Do you just need to know whether or not you've already got a particular value, but without ordering (and you don't need to store duplicates)? Use a set.
Do you need to associate values with keys, so you can look them up efficiently (by key) later on? Use a dictionary. | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 1 | 0 | 0 | 207,368 |
3,489,071 | 2010-08-15T20:22:00.000 | 20 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 3,489,082 | 13 | false | 0 | 0 | Use a dictionary when you have a set of unique keys that map to values.
Use a list if you have an ordered collection of items.
Use a set to store an unordered set of items. | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 1 | 0 | 0 | 207,368 |
3,489,071 | 2010-08-15T20:22:00.000 | 25 | 0 | 1 | 0 | python,list,dictionary,data-structures,set | 3,489,081 | 13 | false | 0 | 0 | When you want an unordered collection of unique elements, use a set. (For example, when you want the set of all the words used in a document).
When you want to collect an immutable ordered list of elements, use a tuple. (For example, when you want a (name, phone_number) pair that you wish to use as an element in a set, you would need a tuple rather than a list since sets require elements be immutable).
When you want to collect a mutable ordered list of elements, use a list. (For example, when you want to append new phone numbers to a list: [number1, number2, ...]).
When you want a mapping from keys to values, use a dict. (For example, when you want a telephone book which maps names to phone numbers: {'John Smith' : '555-1212'}). Note the keys in a dict are unordered. (If you iterate through a dict (telephone book), the keys (names) may show up in any order). | 6 | 331 | 0 | When should I use a dictionary, list or set?
Are there scenarios that are more suited for each data type? | In Python, when to use a Dictionary, List or Set? | 1 | 0 | 0 | 207,368 |
3,489,183 | 2010-08-15T20:47:00.000 | 0 | 0 | 1 | 0 | python,timezone | 71,177,623 | 8 | false | 0 | 0 | Working with the latest version of tzlocal which is 4.1 as of today, tzlocal.get_localzone().key produces the following error: AttributeError: '_PytzShimTimezone' object has no attribute 'key'. But tzlocal.get_localzone().zone works lovely. | 1 | 24 | 0 | In a Python project I'm working on, I'd like to be able to get a "human-readable" timezone name of the form America/New_York, corresponding to the system local timezone, to display to the user. Every piece of code I've seen that accesses timezone information only returns either a numeric offset (-0400) or a letter code (EDT) or sometimes both. Is there some Python library that can access this information, or if not that, convert the offset/letter code into a human-readable name?
If there's more than one human-readable name corresponding to a particular timezone, either a list of the possible results or any one of them is fine, and if there is no human-readable name corresponding to the current time zone, I'll take either an exception or None or [] or whatever.
A clarification: I don't remember exactly what I had in mind when I originally wrote this question, but I think what I really wanted was a way to turn a timezone into a human-readable name. I don't think this question was meant to focus on how to get the system local timezone specifically, but for the specific use case I had in mind, it just happened that the local timezone was the one I wanted the name for. I'm not editing the bit about the local timezone out of the question because there are answers focusing on both aspects. | How can I get a human-readable timezone name in Python? | 0 | 0 | 0 | 22,635 |
3,489,520 | 2010-08-15T22:25:00.000 | 0 | 0 | 0 | 0 | python,gtk | 3,489,566 | 3 | false | 0 | 1 | Given the widget w, what does w.get_name() return? If None, that means the widget has no name property. Maybe you want gtk.glade.get_widget_name(w) instead? (I'm not sure if the name property of the widget and the name for it in the Glade XML from which it was created are the same thing...). | 1 | 10 | 0 | How do I get a widget's "name"?
When I define a GUI using Glade, I can "name" the widgets of the window but how do I recover that property when I have a widget object instance?
I've tried get_property(), get_name() and $widget.name to no avail.
Update: I am using GtkBuilder file format (i.e. XML format).
Resolution: a fix I have used: use the set_property("name", name) method on the widget just after getting it from GtkBuilder. | Python GTK+ widget name | 0 | 0 | 0 | 4,906 |
3,489,968 | 2010-08-16T01:02:00.000 | 3 | 0 | 0 | 1 | python,performance,google-app-engine | 3,490,013 | 1 | true | 1 | 0 | Call start = time.time() as the very first operation in your handling scripts, and, when you're just about done with everything, as the very last thing you output use (a properly formatted version of) time.time() - start.
If you're using templates for your output (e.g., the Django templates that come with app engine -- 0.96 by default, though you can explicitly ask for newer and better ones;-), or jinja2, mako, ...), it's important to be able to use in those templates a tag or filter to request and format such an expression. (You don't want to compute it at the time you call the template's render method, and pass it as part of that method's context, or else you'll fail to account for all the template rendering time in your estimate of "response time"!-). You may have to code and inject such a tag or filter into the "templating language" if your chosen templating language and version doesn't already supply one but is at least minimally extensible;-).
` | 1 | 4 | 0 | Say I wanted to print the response time on my pages like Google do.
How would I go about doing this? | App Engine - Output Response Time | 1.2 | 0 | 0 | 165 |
3,490,543 | 2010-08-16T04:09:00.000 | 4 | 1 | 1 | 0 | python,rubygems | 3,490,551 | 2 | false | 1 | 0 | no it does not have a ruby installer that I know of. It does have easy_install and pip though. Your google-fu is lacking. | 1 | 3 | 0 | With Ruby you can do gem install from the command line to install a module...even if it is not on your machine.
Can you do that with python. Does someone know of a module?
Seth | Does python have a ruby installer like gem that lets you install modules from the command line even if they are not on your machine? | 0.379949 | 0 | 0 | 1,036 |
3,493,092 | 2010-08-16T12:29:00.000 | 33 | 0 | 1 | 0 | python,image-processing,numpy,python-imaging-library | 3,494,982 | 6 | true | 0 | 0 | scipy.misc.imread() will return a Numpy array, which is handy for lots of things. | 2 | 31 | 1 | I want to do some image processing using Python.
Is there a simple way to import .png image as a matrix of greyscale/RGB values (possibly using PIL)? | Convert image to a matrix in python | 1.2 | 0 | 0 | 77,563 |
3,493,092 | 2010-08-16T12:29:00.000 | 7 | 0 | 1 | 0 | python,image-processing,numpy,python-imaging-library | 50,263,426 | 6 | false | 0 | 0 | scipy.misc.imread() is deprecated now. We can use imageio.imread instead of that to read it as a Numpy array | 2 | 31 | 1 | I want to do some image processing using Python.
Is there a simple way to import .png image as a matrix of greyscale/RGB values (possibly using PIL)? | Convert image to a matrix in python | 1 | 0 | 0 | 77,563 |
3,493,244 | 2010-08-16T12:51:00.000 | 0 | 0 | 0 | 0 | python,mobile-website,turbogears | 3,562,868 | 4 | false | 1 | 0 | The simplest version of a "mobile site" is simply CSS. Display a simplified version of the site to USERAGENTS that are identified as mobile. | 1 | 1 | 0 | Is it possible to develop mobile versions of webpages using Turbogears? Can someone please show me an example and how it is done? | Can I use Turbogears to develop mobile sites? | 0 | 0 | 0 | 254 |
3,494,020 | 2010-08-16T14:22:00.000 | 0 | 1 | 0 | 0 | python,tar,bzip2,tarfile | 3,494,091 | 2 | false | 0 | 0 | Bzip2 compresses in large blocks (900 KiB by default, I believe). One method that would speed up the scanning of the tar file dramatically, but would reduce compression performance, would be to compress each file individually and then tar the results together. This is essentially what Zip-format files are (though using zlib compression rather than bzip2). But you could then easily grab the tar index and only have to decompress the specific file(s) you are looking for.
I don't think most tar programs offer much ability to organize files in any meaningful way, though you could write a program to do this for your special case (I know Python has tar-writing libraries though I've only used them once or twice). However, you'd still have the problem of having to decompress most of the data before you found what you were looking for. | 1 | 3 | 0 | I have about 200,000 text files that are placed in a bz2 file. The issue I have is that when I scan the bz2 file to extract the data I need, it goes extremely slow. It has to look through the entire bz2 file to fine the single file I am looking for. Is there anyway to speed this up?
Also, I thought about possibly organizing the files in the tar.bz2 so I can instead have it know where to look. Is there anyway to organize files that are put into a bz2?
More Info/Edit:
I need to query the compressed file for each textfile. Is there a better compression method that supports such a large number of files and is as thoroughly compressed? | Organizing files in tar bz2 file with python | 0 | 0 | 0 | 965 |
3,494,585 | 2010-08-16T15:22:00.000 | 4 | 1 | 0 | 1 | python,unit-testing,build-automation,teamcity | 3,494,671 | 5 | false | 0 | 0 | I think it is more of a social problem rather than a deficiency of the automated systems.
Yes, you can improve the systems in place, but they will be no match for someone thinking of the implications of their commit, and testing it before they hit commit. | 2 | 6 | 0 | We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night.
"Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as.
-> A developer only checks in some of the modified files in his/her workspace.
-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.
How do you deal with this in your organization?
We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin. | Remembering to run tests before commit | 0.158649 | 0 | 0 | 2,165 |
3,494,585 | 2010-08-16T15:22:00.000 | 7 | 1 | 0 | 1 | python,unit-testing,build-automation,teamcity | 3,494,863 | 5 | false | 0 | 0 | In one of the teams I was working before we had an agreement that anyone who breaks the tests buys bacon sandwiches for the whole team the next morning. Its extreme, but it works perfectly! | 2 | 6 | 0 | We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was done at 6PM may stay broken over night.
"Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as.
-> A developer only checks in some of the modified files in his/her workspace.
-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.
How do you deal with this in your organization?
We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin. | Remembering to run tests before commit | 1 | 0 | 0 | 2,165 |
3,494,587 | 2010-08-16T15:22:00.000 | 1 | 0 | 0 | 0 | python,gtk | 3,495,112 | 2 | true | 0 | 1 | I found out I can use gtk.get_current_event_time() to get a reasonable timestamp matching what Gtk looks like it expects. | 1 | 0 | 0 | What is the format of the parameter activate_time in Python GTK+ when using Gtk.Menu.popup() method?
I have tried using int(time.time()) but I get a traceback saying an integer is required... | Format of activate_time in Gtk.Menu | 1.2 | 0 | 0 | 132 |
3,497,883 | 2010-08-16T22:20:00.000 | 7 | 0 | 1 | 0 | python | 3,497,914 | 3 | false | 0 | 0 | I do this frequently for classes that abstract database tables where there is often a field called id because there is no reasonable chance of a name conflict. Be advised that some synatax highlighters will mark it as a builtin function. | 2 | 37 | 0 | I know that there's a function called id so I wouldn't create a function or a variable called id, but what about an attribute on an object? | In Python is it bad to create an attribute called 'id'? | 1 | 0 | 0 | 5,692 |
3,497,883 | 2010-08-16T22:20:00.000 | 36 | 0 | 1 | 0 | python | 3,497,915 | 3 | true | 0 | 0 | That's ok, and is pretty common. For example, objects mapped to a database record will often have an "id" attribute mapped to the database "id" column value.
Attributes are always "namespaced" so you have to refer to them via self.id or obj.id so there's no conflict with the built-in function. | 2 | 37 | 0 | I know that there's a function called id so I wouldn't create a function or a variable called id, but what about an attribute on an object? | In Python is it bad to create an attribute called 'id'? | 1.2 | 0 | 0 | 5,692 |
3,498,587 | 2010-08-17T01:00:00.000 | 2 | 0 | 1 | 1 | python,file | 3,498,742 | 2 | true | 0 | 0 | You can specify the path to the file in either a complete way (e.g. 'c:/wher/ever/the.txt'), also known as "absolute" because it's taken exactly as you specify it, or a partial one (e.g., just "the.txt", or "ever/the.txt", or "../ever/the.txt", and so on), also known as "relative" because it's taken relatively to the current working directory of your process. If you don't know that working directory, an absolute path is usually simplest to find and specify.
So, find out where the file lives (e.g. c:/wher/ever) and use that absolute path (with "rightside up slashes", instead of windows-style backslashes, as I just explained in another answer) to open the file in question. | 1 | 2 | 0 | I'm trying to open a file with Python, but I'm unsure how to find the correct filename to use. | How do you find the filename that you pass to open()? | 1.2 | 0 | 0 | 965 |
3,498,904 | 2010-08-17T02:28:00.000 | 0 | 0 | 1 | 0 | python,windows,validation | 3,498,920 | 2 | false | 0 | 0 | I would really urge you not to do this. As you said, whatever you do will be broken, and you may actually cause more copies of your software to be pirated by including this barrier. Asking your users nicely not to steal may do better...
That said, implementing this in a way that discourages the most casual piracy is easy: just have the program send a serial number encrypted with the server's public key to your validation script, and have the server return a version of the number encrypted using its private key. Instant validation. Yes, this server could be written in Python easily. | 2 | 0 | 0 | I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of software validation server be written in Python? How would the software communicate with the server? Would the softwre check each time it is launched to see if it is valid? The program requires internet access to run anyway, so checking for validation at each launch might not be so bad.
I am programming in Python 2.6 on Windows 7. Any help would be great! | Software Validation Server in Python? | 0 | 0 | 0 | 228 |
3,498,904 | 2010-08-17T02:28:00.000 | 2 | 0 | 1 | 0 | python,windows,validation | 3,498,935 | 2 | true | 0 | 0 | The software, when starting, should launch an https (so it can't just be sniffed easily;-) request to your server, identifying itself (however it is that you choose to identify, e.g. a serial number or whatever), and the server's response will tell it what to do (run normally, or terminate, or ask the user to register -- whatever).
Of course, any competent hacker will find and disable the part of your code where you're sending the request and dispatching on the answer, but then you already do know that everything can easily be cracked;-).
A less-easily crackable approach would be to keep some crucial part of the functionality on your server, so that the client's basically useless (or at least less useful) if it hasn't checked in with your server and obtained a token to be used in other "functionality requests" during a session.
Hard to tell, without knowing a lot more about your app, if there are bits and pieces of functionality in your app that lend themselves well to this treatment, but for example you could delegate in this way any kind of cryptographic functionality (encrypting, decrypting, signing, ...) -- if only your server knows the secret/private keys to be used for such purposes, and only performs the functionality for application sessions that have properly registered and been authorized, suddenly it's become very hard for even a good hacker to work around your registration and authorization system. | 2 | 0 | 0 | I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of software validation server be written in Python? How would the software communicate with the server? Would the softwre check each time it is launched to see if it is valid? The program requires internet access to run anyway, so checking for validation at each launch might not be so bad.
I am programming in Python 2.6 on Windows 7. Any help would be great! | Software Validation Server in Python? | 1.2 | 0 | 0 | 228 |
3,501,068 | 2010-08-17T09:28:00.000 | 1 | 0 | 0 | 0 | python,rtf | 3,501,153 | 2 | false | 0 | 0 | PyRTF is abandonware and doesn't realy have anything in the way of documentation other than the examples. I don't know about columns, but it does support tables so you might be able to achieve the layout you want that way. | 1 | 0 | 0 | Can anybody reccomend a way of generating a multi column RTF document with python, i was going to use PyRTF but i cant find any documentation on how to set up columns. i think i might need to edit the modules source any reccomendations? | Python RTF Multi Column layout | 0.099668 | 0 | 0 | 548 |
3,501,215 | 2010-08-17T09:51:00.000 | 0 | 0 | 0 | 0 | python,opengl,svg,cairo,rsvg | 37,703,846 | 3 | false | 0 | 1 | I had to do the same (changing element color for instance), and had to modify rsvg library because all those nice features exist but they are hidden. You have to make a new interface to link to the nice features. | 1 | 3 | 0 | I render a huge SVG file with a lot of elements with Cairo, OpenGL and rsvg. I draw svg on cairo surface via rsvg and create an OpenGL texture to draw it. Everything is fine. And now I have to interact with elements from SVG. For example, I want to guess an element by coordinates. And I want to change the background of some path in SVG. In the case of changing background I think, I can change SVG DOM and somehow re-render a part of SVG. But in the case of hit testing elements I'm totally embarrassed.
So, is there some python library to interact with SVG? Is it possible to stay with cairo and rsvg and how can I implement it myself? Or is there a better way to render SVG in OpenGL and interact with it in python? All I want is load SVG, manipulate its DOM and render it | SVG interaction in python with cairo, opengl and rsvg | 0 | 0 | 0 | 3,978 |
3,501,382 | 2010-08-17T10:15:00.000 | 3 | 0 | 1 | 0 | python,integer | 17,510,248 | 41 | false | 0 | 0 | If you just need the value, operator.index (__index__ special method) is the way to go in my opinion. Since it should work for all types that can be safely cast to an integer. I.e. floats fail, integers, even fancy integer classes that do not implement the Integral abstract class work by duck typing.
operator.index is what is used for list indexing, etc. And in my opinion it should be used for much more/promoted.
In fact I would argue it is the only correct way to get integer values if you want to be certain that floating points, due to truncating problems, etc. are rejected and it works with all integral types (i.e. numpy, etc.) even if they may not (yet) support the abstract class.
This is what __index__ was introduced for! | 1 | 1,068 | 0 | How do I check whether a variable is an integer? | Checking whether a variable is an integer or not | 0.014633 | 0 | 0 | 1,713,701 |
3,503,970 | 2010-08-17T15:11:00.000 | 0 | 0 | 1 | 0 | python,pyc | 3,504,112 | 6 | false | 0 | 0 | Well, I don't think Python ever interprets code directly if you're loading the code from a file. Even when using the interactive shell, Python will compile the imported module into a .pyc.
That said, you could write a shell script to go ahead and delete all the .pyc files before launching your scripts. That would certainly force a full rebuild before every execution. | 3 | 24 | 0 | Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case.
(Why do I want to do this? I have a large pipeline of Python scripts which are run repeatedly over a cluster of a couple hundred computers. The Python scripts themselves live on a shared NFS filesystem. Somehow, rarely, after having been run hundreds of times over several hours, they will suddenly start crashing with an error about not being able to import a module. Forcing the regeneration of the .pyc file fixes the problem. I want, of course, to fix the underlying causes, but in the meantime we also need the system to continue running, so it seems like ignoring the .pyc files if possible would be a reasonable workaround).
P.S. I'm using Python 2.5, so I can't use -B. | Make Python ignore .pyc files | 0 | 0 | 0 | 7,661 |
3,503,970 | 2010-08-17T15:11:00.000 | 0 | 0 | 1 | 0 | python,pyc | 3,503,998 | 6 | false | 0 | 0 | Perhaps you could work around this by, for example, scheduling a job to periodically shut down the scripts and delete the .pyc files. | 3 | 24 | 0 | Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case.
(Why do I want to do this? I have a large pipeline of Python scripts which are run repeatedly over a cluster of a couple hundred computers. The Python scripts themselves live on a shared NFS filesystem. Somehow, rarely, after having been run hundreds of times over several hours, they will suddenly start crashing with an error about not being able to import a module. Forcing the regeneration of the .pyc file fixes the problem. I want, of course, to fix the underlying causes, but in the meantime we also need the system to continue running, so it seems like ignoring the .pyc files if possible would be a reasonable workaround).
P.S. I'm using Python 2.5, so I can't use -B. | Make Python ignore .pyc files | 0 | 0 | 0 | 7,661 |
3,503,970 | 2010-08-17T15:11:00.000 | 6 | 0 | 1 | 0 | python,pyc | 24,909,688 | 6 | false | 0 | 0 | In case anyone is using python 2.6 or above with the same question, the simplest thing to do is:
Delete all .pyc files
Run all your python interpreters with the -B option, so they won't generate .pyc files.
From the docs:
-B
If given, Python won’t try to write .pyc or .pyo files on the import of source modules. See also PYTHONDONTWRITEBYTECODE.
New in version 2.6.
If you can't delete all the .pycs, then you could:
1) Run all your python interpreters with the -B -O options.
This will tell python to look for .pyo files for bytecode instead of .pyc files (-O) and tell python not to generate any bytecode files (-B).
The combination of the two options, assuming you haven't used them before, is that Python won't generate any bytecode files and won't look for bytecode files that would have been generated by older runs.
From the docs:
-B
If given, Python won’t try to write .pyc or .pyo files on the import of source modules. See also PYTHONDONTWRITEBYTECODE.
New in version 2.6.
-O
Turn on basic optimizations. This changes the filename extension for compiled (bytecode) files from .pyc to .pyo. See also PYTHONOPTIMIZE. | 3 | 24 | 0 | Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case.
(Why do I want to do this? I have a large pipeline of Python scripts which are run repeatedly over a cluster of a couple hundred computers. The Python scripts themselves live on a shared NFS filesystem. Somehow, rarely, after having been run hundreds of times over several hours, they will suddenly start crashing with an error about not being able to import a module. Forcing the regeneration of the .pyc file fixes the problem. I want, of course, to fix the underlying causes, but in the meantime we also need the system to continue running, so it seems like ignoring the .pyc files if possible would be a reasonable workaround).
P.S. I'm using Python 2.5, so I can't use -B. | Make Python ignore .pyc files | 1 | 0 | 0 | 7,661 |
3,504,383 | 2010-08-17T15:52:00.000 | 0 | 0 | 0 | 0 | python,wxpython,resolution-independence | 3,526,358 | 2 | false | 0 | 1 | Did you try calling the GetNumberOfLines() method? According to Robin Dunn, that should work, although it doesn't take wrapped lines into account. | 1 | 2 | 0 | I'm writing an e-book reader in Python + wxPython, and I'd like to find out how many lines of text can be displayed in a given RichTextCtrl with the current formatting without scrolling.
I thought of using and dividing the control's height by RichTextCtrl.GetFont().GetPixelSize(), but it appears that the pixel size parameter of wx.Font is only specified on Windows and GTK. In addition, this won't cover any additional vertical spacing between lines/paragraphs.
I could of course get the font size in points, attempt to get the display's resolution in ppi, and do it that way, but 1) the line spacing problem still remains and 2) this is far too low a level of abstraction for something like this.
Is there a sane way of doing this?
EDIT: The objective is, to divide the ebook up into pages, so the scrolling unit is a whole page, as opposed to a line. | Finding out how many lines can be displayed in wx.richtext.RichTextCtrl without scrolling | 0 | 0 | 0 | 445 |
3,504,405 | 2010-08-17T15:54:00.000 | 1 | 0 | 0 | 0 | python,django,architecture,code-organization | 3,504,714 | 2 | true | 1 | 0 | I would create subdirectory named rules in the app with game logic and there create module named after each game, that you would like serve. Then create a common interface for those modules, that will be utilized by your games and import proper rules module by name (if your game is called adom, then simply __import__('rules.adom') inside the main game engine and call game specific methods.
If your games don't create own models and views, then there seems to be no reason to create specific app for each of them. This is a delicate matter, because code used is based on data stored in the database. Didn't you think about storing additional gaming scripts inside the database to and then exec them? This seems more natural: a game is set of data and additional scripts associated with that game. | 2 | 4 | 0 | I'm designing (and ultimately writing) a system in Django that consists of two major components:
A Game Manager: this is essentially a data-entry piece. Trusted (non-public) users will enter information on a gaming system, such as options that a player may have. The interface for this is solely the Django admin console, and it doesn't "do" anything except hold the information.
A Character Manager: this is the consumer of the above data. Public users will create characters in the role-playing systems defined above, pulling from the options entered by those trusted users. This is a separate app in the project from Django's standpoint.
There's one piece I'm not sure where to put, however, and that is the "rules" that are associated with each game. Essentially, for each game put into the first app, there are a sets of prerequisites, limitations, and other business logic specific to that game. (There's also similarly-structured logic that will be common to all games.) The logic is going to be coded in Python, rather than user-entered.
That logic is used in the process of validating a particular character, but is associated with a particular game and will need to be swapped out dynamically. Is it a separate app, or should it be validation tied to the forms of the Character Manager? Or can it be both?
This is the first Django app I've built from scratch (rather than chewing on someone else's code), and I'm new to the Python philosophy to boot, so I'm all ears on this.
Thanks in advance. | How to best organize the rules component of a Django system? | 1.2 | 0 | 0 | 177 |
3,504,405 | 2010-08-17T15:54:00.000 | 1 | 0 | 0 | 0 | python,django,architecture,code-organization | 3,504,959 | 2 | false | 1 | 0 | the "rules" that are associated with each game.
for each game put into the first app, there are a sets of prerequisites, limitations, and other business logic specific to that game.
That's part of the game app, then.
There's also similarly-structured logic that will be common to all games.
That's part of the game app, then.
That logic is used in the process of validating a particular character, but is associated with a particular game.
Correct. That's part of the game app, then. Characters are associated with one or more games.
should it be validation tied to the forms of the Character Manager?
The Character Forms can have data cleansing rules which depend on a Game. | 2 | 4 | 0 | I'm designing (and ultimately writing) a system in Django that consists of two major components:
A Game Manager: this is essentially a data-entry piece. Trusted (non-public) users will enter information on a gaming system, such as options that a player may have. The interface for this is solely the Django admin console, and it doesn't "do" anything except hold the information.
A Character Manager: this is the consumer of the above data. Public users will create characters in the role-playing systems defined above, pulling from the options entered by those trusted users. This is a separate app in the project from Django's standpoint.
There's one piece I'm not sure where to put, however, and that is the "rules" that are associated with each game. Essentially, for each game put into the first app, there are a sets of prerequisites, limitations, and other business logic specific to that game. (There's also similarly-structured logic that will be common to all games.) The logic is going to be coded in Python, rather than user-entered.
That logic is used in the process of validating a particular character, but is associated with a particular game and will need to be swapped out dynamically. Is it a separate app, or should it be validation tied to the forms of the Character Manager? Or can it be both?
This is the first Django app I've built from scratch (rather than chewing on someone else's code), and I'm new to the Python philosophy to boot, so I'm all ears on this.
Thanks in advance. | How to best organize the rules component of a Django system? | 0.099668 | 0 | 0 | 177 |
3,504,522 | 2010-08-17T16:05:00.000 | 2 | 0 | 0 | 0 | python,image,pyqt,selection,pixel | 3,543,483 | 3 | false | 0 | 1 | First you have to draw the image. You can do this my making a QLabel widget and call setPixmap. You need to convert your QImage to QPixmap before doing this (you can use QPixmap.fromImage(img)).
You can get mouse clicks by subclassing the QImage and intercepting mousePressEvent. Look up the pixel value with QImage.pixel(). | 1 | 9 | 0 | I would like to know how i can select a pixel with a mouse click in an image (QImge) and get pixel position and value.
Thanks | Pyqt get pixel position and value when mouse click on the image | 0.132549 | 0 | 0 | 19,296 |
3,506,105 | 2010-08-17T19:20:00.000 | 3 | 1 | 0 | 0 | python,emacs | 6,899,728 | 2 | true | 0 | 0 | Ropemacs does the job : Use the function rope-show-doc over the symbol or use the keybinding C-c d. Simple :) | 2 | 7 | 0 | I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6.
In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work? | Quickhelp for Python in Emacs autocomplete.el? | 1.2 | 0 | 0 | 607 |
3,506,105 | 2010-08-17T19:20:00.000 | 1 | 1 | 0 | 0 | python,emacs | 6,889,131 | 2 | false | 0 | 0 | I stopped using all the autocomplete stuff in all my developing environments. They rarely do what I want. Either the lists is too long, or too short, or not sorted well. Therefore I use dabbrev-expand in all my modes global-set-key to tab.
This works even quote well for text. Usually it is enough to get a good expansion from the local buffer where you are in. If I start typing in an empty buffer I open a second one which expand can use to look up its suggestions. This is not language sensitive, not does depend on the object you want to call a method of, but its still a big boost, and you get used to it. Maybe its not, you don't get "quick help" this way. | 2 | 7 | 0 | I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6.
In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possible to enable it and did somebody make it work? | Quickhelp for Python in Emacs autocomplete.el? | 0.099668 | 0 | 0 | 607 |
3,506,252 | 2010-08-17T19:35:00.000 | 6 | 1 | 0 | 0 | java,python,qt,programming-languages,replace | 3,506,325 | 10 | false | 1 | 0 | Might be worth loking at the other JVM languages - Clojure and Scala are the two I personally think are most promising.
Yes you are on the JVM, but you're pretty independent from Java the langauage and don't have to use any Sun/Oracle implementations if you don't want to.
Having said that - I think that you are worrying a little too much about Java, too many players (including Oracle!) have too much invested to let it go too far off course. | 3 | 3 | 0 | I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement.
I am fluent in C#/VB.NET too but I am looking for something more like:
Open Source
Compiled
Cross-Platform
Object Oriented
Large standard library
Extensive documentation
Web development is a major plus
I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts? | What languages would be a good replacement for Java? | 1 | 0 | 0 | 3,718 |
3,506,252 | 2010-08-17T19:35:00.000 | 0 | 1 | 0 | 0 | java,python,qt,programming-languages,replace | 3,509,044 | 10 | false | 1 | 0 | C# is the only thing that will meet your needs and not feel hopelessly archaic, or frustrate with limited library. For open source/non-windows, use mono. It's a good, mature implementation of most of what's important in the CLR.
Some things (WPF, WCF, etc) are "missing" from mono, but these aren't so much part of the platform as they are windows-specific proprietary toolkits. Some of them are being implemented slowly in mono, some aren't. Coming from java you won't miss them because you're looking for a platform and good standard libraries to build upon, not a gui toolkit or whiz-bang communication framework.
As far as a platform to build stuff with that's "like" java and offers similar levels of functionality, C# + CLR is the clearest option. | 3 | 3 | 0 | I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement.
I am fluent in C#/VB.NET too but I am looking for something more like:
Open Source
Compiled
Cross-Platform
Object Oriented
Large standard library
Extensive documentation
Web development is a major plus
I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts? | What languages would be a good replacement for Java? | 0 | 0 | 0 | 3,718 |
3,506,252 | 2010-08-17T19:35:00.000 | 1 | 1 | 0 | 0 | java,python,qt,programming-languages,replace | 3,506,402 | 10 | false | 1 | 0 | I too would like another Java-like technology to come along. Lately I've been doing Flex/Actionscript. While I really enjoy it, Actionscript technology seriously lacks the elegance that Java has. Adobe can write some good cross platform APIs, but they just don't have the head capital to build elegant languages and compilers. I've also tried Ruby, but the VM for Ruby is really bad. I've gone back to Java after my flirtation with other technologies and I think it's because the language is good enough, but the JVM is by far the best out there.
So do you want to stay with the JVM or do you really want to the leave the JVM altogether? Staying on the JVM there are lots of options: JRuby, Scala, Groovy, Javascript, Clojure are the big players. However, there are tons of great languages that can take advantage of the JVM's features.
Leaving the JVM there are still good options like python, ruby, and erlang. But you give up some of the nice features of the JVM like performance (big one), and the ability to drop down to a nice language like Java if you need speed. Those others mean using C or nothing at all.
I finally stopped worrying about Java's future. Sun did all it could to screw it up and it still turned out pretty darn good. I think Opensource has a lot more influence over Java's success than Oracle or Sun could ever have had. | 3 | 3 | 0 | I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement.
I am fluent in C#/VB.NET too but I am looking for something more like:
Open Source
Compiled
Cross-Platform
Object Oriented
Large standard library
Extensive documentation
Web development is a major plus
I was thinking about a compromise: Python/Django for web development (or PHP), and Qt for thick client development. Anyone with better thoughts? | What languages would be a good replacement for Java? | 0.019997 | 0 | 0 | 3,718 |
3,507,451 | 2010-08-17T22:22:00.000 | 0 | 0 | 1 | 0 | python,multithreading,r | 3,507,504 | 6 | false | 0 | 0 | If I remember correctly (but I might be wrong here) one of the main purposes of Ada95 was parallel processing. Funny language, that was.
Jokes aside I'm not quite sure how good performance wise it would be (but seeing you are using Python now then it shouldn't be that bad) but I'd suggest Java since the basics of multithreading are quite simple there (but making a well written, complex multithreaded application is rather hard). Heard the Concurrency library is also quite nice, I haven't tried it out myself yet, though. | 2 | 6 | 0 | Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing.
For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step.
From my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language/implementation for this type of data processing? | Recommended language for multithreaded data work | 0 | 0 | 0 | 657 |
3,507,451 | 2010-08-17T22:22:00.000 | 1 | 0 | 1 | 0 | python,multithreading,r | 3,507,522 | 6 | false | 0 | 0 | On the Python side, your best bet is probably to separate the two steps in two different processes. There are a couple of modules that help you to achieve that. You would couple the two processes through pipes. In order to pass arbitrary data through the pipe, you need to serialize and deserialize it. The pickle module would be a good candidate for this.
If you want to jump ship, languages like Erlang, Haskell, Scala or Clojure have probably the concurrency features you are looking for, but I don't know how well they would integrate with R or some other statistical package that suits you. | 2 | 6 | 0 | Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing.
For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step.
From my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language/implementation for this type of data processing? | Recommended language for multithreaded data work | 0.033321 | 0 | 0 | 657 |
3,507,543 | 2010-08-17T22:39:00.000 | 1 | 0 | 0 | 0 | python,postgresql,sqlalchemy,rsa,pycrypto | 3,507,558 | 2 | false | 0 | 0 | By "same key" you mean "the other key", right? RSA gives you a keypair, if you encrypt with one you decrypt with the other ...
Other than that, it sounds like a encoding problem. Try storing the data as binary or encode the string with your databases collation.
Basically encryption gives you bytes but you store them as a string (encoded bytes). | 1 | 1 | 0 | I want to encrypt a string using RSA algorithm and then store that string into postgres database using SQLAlchemy in python. Then Retrieve the encrypted string and decrypt it using the same key. My problem is that the value gets stored in the database is not same as the actual encrypted string. The datatype of column which is storing the encrypted value is bytea. I am using pycrypto library. Do I need to change the data in a particular format before inserting it to database table?
Any suggestions please.
Thanks,
Tara Singh | Inserting Encrypted Data in Postgres via SQLALchemy | 0.099668 | 1 | 0 | 3,897 |
3,507,732 | 2010-08-17T23:20:00.000 | 3 | 1 | 0 | 0 | python,arduino | 3,507,854 | 3 | false | 0 | 0 | Encode them into binary strings with Python's struct module. I don't know if arduino wants them little-endian or big-endian, but, if its docs aren't clear about this, a little experiment should easily settle the question;-). | 1 | 1 | 0 | I need to send integers greater than 255? Does anyone know how to do this? | Sending integer values to Arduino from PySerial | 0.197375 | 0 | 0 | 14,924 |
3,507,925 | 2010-08-18T00:00:00.000 | 1 | 0 | 1 | 0 | python | 3,507,956 | 3 | false | 0 | 0 | Quick-and-dirty solution is to use s[::2] where s is the 80-characters byte string of which you want to consider only alternate bytes. The "clean: solution, per @fadden's comment, might be to read in the data as UTF-16 (then .encode it to ASCII, etc), but if the Q&D one suffices for your purposes, it might be simpler and faster (if the original data has characters that are not in the lowest 256 range, the Q&D approach will give strange results while the proper one would raise an exception -- which treatment is better depends on you app...). | 1 | 3 | 0 | I have some binary data, in hex editor it looks like:
s.o.m.e.d.a.t.a
with all these dots in between each letter
when I read with filehandle.read(40)
it shows these dots
I know that the dots aren't supposed to be there, is there a way to unpack some ascii data that is 40 bytes long with struct?
I tried '40s' and 's' but it shows weird data, or only unpacks 1 character instead of 40. | Read 40 bytes of binary data as ascii text | 0.066568 | 0 | 0 | 3,727 |
3,507,980 | 2010-08-18T00:13:00.000 | 0 | 1 | 0 | 1 | python,ssh | 3,508,010 | 3 | false | 0 | 0 | Am I correct in assuming you're running your script on some sort of UNIX/Linux system? If so, you can just type "users" on the command-line, and it will show you the currently logged in users.
Also, if you call the "lastlog" command, that will show you all the users on the system and the last time they all logged in to the machine. | 2 | 1 | 0 | How can I know if the user is connected to the local machine via ssh in my python script? | How can I know if the user is connected to the local machine via ssh in my python script? | 0 | 0 | 0 | 416 |
3,507,980 | 2010-08-18T00:13:00.000 | 0 | 1 | 0 | 1 | python,ssh | 3,508,136 | 3 | false | 0 | 0 | Check any of the SSH variables SSH_CONNECTION, SSH_CLIENT, or SSH_TTY. However, these can be unset by the user.
Check the output of who am i. It will end with the remote system identification in brackets if you are connected remotely. Make sure to handle x-term sessions which will have a colon (:) in the remote system id. | 2 | 1 | 0 | How can I know if the user is connected to the local machine via ssh in my python script? | How can I know if the user is connected to the local machine via ssh in my python script? | 0 | 0 | 0 | 416 |
3,509,275 | 2010-08-18T05:44:00.000 | 2 | 0 | 0 | 0 | python,django,django-models,many-to-many | 3,509,354 | 1 | true | 1 | 0 | If I have two classes A and B with a many to many relationship and I want to delete an instance of A, do I need to remove all of its related Bs first or will Django sort that out for me?
Short answer: Django will sort that out for you.
Does it make any difference if the ManyToMany field is declared on class A or B?
As far as I know, no, it does not make a difference.
Does it make any difference if there are additional fields on a join class specified using the "through" parameter?
I haven't tried this myself but I don't see why there should be a problem. | 1 | 0 | 0 | If I have two classes A and B with a many to many relationship and I want to delete an instance of A, do I need to remove all of its related Bs first or will Django sort that out for me?
I obviously don't want to leave orphaned rows in the join table.
Does it make any difference if the ManyToMany field is declared on class A or B?
Does it make any difference if there are additional fields on a join class specified using the "through" parameter? | Can deleting a django Model with a ManyToManyField create orphaned database rows? | 1.2 | 0 | 0 | 334 |
3,509,471 | 2010-08-18T06:28:00.000 | 1 | 0 | 1 | 0 | python,windows-7,registry,editing,access-denied | 3,509,560 | 1 | false | 0 | 0 | If you want to edit something that is writable only with administrative privileges, you just have to run under admin privileges. Everything else would be a giant security hole. | 1 | 1 | 0 | I have run into another problem with my current project. The program needs to values and keys periodically while running. Each time I attempt to edit the value, I get a code 5, Access Denied. How would I go about doing this so the values can be editied, but the user doesn't have to enter admin credentials to run the application?
I am using the _winreg module with Python 2.6 on Windows 7. | Edit Windows 7 Registry in Python? | 0.197375 | 0 | 0 | 1,429 |
3,510,374 | 2010-08-18T08:51:00.000 | 1 | 0 | 0 | 0 | python,django,tinymce,django-filebrowser,django-grappelli | 7,351,831 | 3 | false | 1 | 0 | I managed to get the admin site to look like the django simple admin interface by not setting my admin media prefix to '/media/grappelli/'. Just left it as '/static/admin/' and it didn't break anything seemingly, I've not been able to get the 'choose' to work either way though. | 1 | 1 | 0 | So, I found django admin interface called 'grappelli'. Looked at the screenshots and decided that I like it. Went to sources page and checked out trunk. Set it up and noticed that it looks nothing like screenshots. No dashboard, no side panel, different colors of the elements and model item lists are very narrow.
From that point I'm wondering if I did something wrong and read the docs more closely. Stumbled upon admin-tools, installed them too. Dashboard appeared but it had misplaced buttons and different placements of the elements again. And haven't solved the problems with narrow item lists.
That was rather disappointing, but I decided to lurk more. And checked out branch 2_2. This finally looked like the screenshots in the django project. And tiny mce worked too!
So, question one: is this what everybody who want use grappelli do? Or are those screenshots actually for trunk version and it's just shy to show its beauty to me?
After that I decided to install filebrowser. Went to google project page, read the instruction, noticed grapplelli requirement and rejoiced thinking it'd be easy since I already got it.
So, I checked out trunk, placed the media where it belongs, created paths necessary and it worked. But looked awful. Search field and filters are nothing like in the simple django admin or grappelli, list is narrow, filters do not work. And weird gear like buttons on the right do not work either.
Well, it didn't discourage me to browse through templates, fix them here and there and they started to look more or less ok. But weird gear like buttons still didn't work. And what's worse, image insertion dialog from tiny MCE wasn't working either. It appeared, showed my folders and files but 'Choose' button was disabled.
Now I start to think that I did something wrong and
I reverted filebrowser back to trunk. 'Choose' buttons still don't work.
I wiped out everything and reverted grappelli to trunk. Filebrowser still looks somewhat messed up and worst of all 'Choose' buttons still don't work.
I tried filebrowser-no-grappelli and it doesn't even have those buttons.
I gave up and went here seeking comfort
So, question two: does everybody who wants to use filebrowser with tiny MCE insert image dialog walk the same path? Have you managed to make it work? Please, help me do the same.
TL/DR: How to set up grappelli and filebrowser for django admin and make tiny MCE insert image dialogs work?
I use django 1.2.1. | django grappelli, filebrowser and Tiny MCE insert image dialog | 0.066568 | 0 | 0 | 2,709 |
3,510,747 | 2010-08-18T09:41:00.000 | 6 | 1 | 1 | 0 | python,logging | 3,510,824 | 1 | true | 0 | 0 | imaplib is much older (it was in Python1.5.2) than the logging module (Python2.3), so perhaps noone has needed to update it to use logging yet | 1 | 1 | 0 | I'm not sure if it's because sys.stderr.write is faster. | Why does python libs (eg imaplib) does not use logging but use sys.stderr.write? | 1.2 | 0 | 0 | 72 |
3,511,027 | 2010-08-18T10:19:00.000 | 23 | 0 | 1 | 0 | python,design-patterns,factory,factory-pattern | 3,511,165 | 3 | false | 0 | 0 | Be Pythonic. Don't overcomplicate your code with "enterprise" language (like Java) solutions that add unnecessary levels of abstraction.
Your code should be simple, and intuitive. You shouldn't need to delegate to another class to instantiate another. | 2 | 23 | 0 | I'm currently implementing the Factory design pattern in Python and I have a few questions.
Is there any way to prevent the direct instantiation of the actual concrete classes? For example, if I have a VehicleFactory that spawns Vehicles, I want users to just use that factory, and prevent anyone from accidentally instantiating Car() or Truck() directly. I can throw an exception in init() perhaps, but that would also mean that the factory can't create an instance of it...
It seems to me now that factories are getting addictive. Seems like everything should become a factory so that when I change internal implementation, the client codes will not change. I'm interested to know when is there an actual need to use factories, and when is it not appropriate to use. For example, I might have a Window class and there's only one of this type now (no PlasticWindow, ReinforcedWindow or anything like that). In that case, should I use a factory for the client to generate the Window, just in case I might add more types of Windows in the future?
I'm just wondering if there is a usual way of calling the factories. For example, now I'm calling my Vehicle factory as Vehicles, so the codes will go something like Vehicles.create(...). I see a lot of tutorials doing it like VehicleFactory, but I find it too long and it sort of exposes the implementation as well.
EDIT: What I meant by "exposes the implementation" is that it lets people know that it's a factory. What I felt was that the client need not know that it's a factory, but rather as some class that can return objects for you (which is a factory of course but maybe there's no need to explicitly tell clients that?). I know that the soure codes are easily exposed, so I didn't mean "exposing the way the functionalities are implemented in the source codes".
Thanks! | Factory pattern in Python | 1 | 0 | 0 | 16,908 |
3,511,027 | 2010-08-18T10:19:00.000 | 6 | 0 | 1 | 0 | python,design-patterns,factory,factory-pattern | 3,511,337 | 3 | false | 0 | 0 | Is there any way to prevent the direct instantiation of the actual concrete classes?
Why? Are your programmers evil sociopaths who refuse to follow the rules? If you provide a factory -- and the factory does what people need -- then they'll use the factory.
You can't "prevent" anything. Remember. This is Python -- they have the source.
should I use a factory for the client to generate the Window, just in case I might add more types of Windows in the future?
Meh. Neither good nor bad. It can get cumbersome to manage all the class-hierarchy-and-factory details.
Adding a factory isn't hard. This is Python -- you have all the source at all times -- you can use grep to find a class constructor and replace it with a factory when you need to.
Since you can use grep to find and fix your mistakes, you don't need to pre-plan this kind of thing as much as you might in Java or C++.
I see a lot of tutorials doing it like VehicleFactory, but I find it too long and it sort of exposes the implementation as well.
"Too Long"? It's used so rarely that it barely matters. Use long names -- it helps other folks understand what you're doing. This is not Code Golf where fewest keystrokes wins.
"exposes the implementation"? First, It exposes nothing. Second, this is Python -- you have all the source at all times -- everything is already exposed.
Stop thinking so much about prevention and privacy. It isn't helpful. | 2 | 23 | 0 | I'm currently implementing the Factory design pattern in Python and I have a few questions.
Is there any way to prevent the direct instantiation of the actual concrete classes? For example, if I have a VehicleFactory that spawns Vehicles, I want users to just use that factory, and prevent anyone from accidentally instantiating Car() or Truck() directly. I can throw an exception in init() perhaps, but that would also mean that the factory can't create an instance of it...
It seems to me now that factories are getting addictive. Seems like everything should become a factory so that when I change internal implementation, the client codes will not change. I'm interested to know when is there an actual need to use factories, and when is it not appropriate to use. For example, I might have a Window class and there's only one of this type now (no PlasticWindow, ReinforcedWindow or anything like that). In that case, should I use a factory for the client to generate the Window, just in case I might add more types of Windows in the future?
I'm just wondering if there is a usual way of calling the factories. For example, now I'm calling my Vehicle factory as Vehicles, so the codes will go something like Vehicles.create(...). I see a lot of tutorials doing it like VehicleFactory, but I find it too long and it sort of exposes the implementation as well.
EDIT: What I meant by "exposes the implementation" is that it lets people know that it's a factory. What I felt was that the client need not know that it's a factory, but rather as some class that can return objects for you (which is a factory of course but maybe there's no need to explicitly tell clients that?). I know that the soure codes are easily exposed, so I didn't mean "exposing the way the functionalities are implemented in the source codes".
Thanks! | Factory pattern in Python | 1 | 0 | 0 | 16,908 |
3,511,922 | 2010-08-18T12:15:00.000 | 2 | 1 | 1 | 0 | java,python,gil | 3,512,342 | 5 | false | 0 | 0 | After reading your updated spec:
I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU
What exactly does "computing extensive" mean? What problem domain? What do others who work in this problem domain use? If you are serious with this specification, you can't do much other things than using C++ in connection with well-tested libraries for multithreading and numerical computing.
my $0.02
rbo | 2 | 4 | 0 | Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL?
I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad.
Java is nice, but I need something more 'embedable' without bulky JRE.
Update: Anything .NET-related or non-open source is a no-go.
Update2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU.
Update3: Target platform is Linux(Debian) on x86 | Looking for strong/explicit-typed language without GIL | 0.07983 | 0 | 0 | 887 |
3,511,922 | 2010-08-18T12:15:00.000 | 4 | 1 | 1 | 0 | java,python,gil | 3,512,157 | 5 | false | 0 | 0 | Anything in the ML family might work for you. Ocaml is a great place to start, but it does have a stop-the-world GC last I looked. Haskell is famous as a lab for innovative concurrency models. Python's comprehensions came from Haskell, where they'rr a convenient syntax for some very fundamental ideas. And Erlang is strongly dynamcally typed, fun to write in, and does concurrency better than anybody else. | 2 | 4 | 0 | Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL?
I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad.
Java is nice, but I need something more 'embedable' without bulky JRE.
Update: Anything .NET-related or non-open source is a no-go.
Update2: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU.
Update3: Target platform is Linux(Debian) on x86 | Looking for strong/explicit-typed language without GIL | 0.158649 | 0 | 0 | 887 |
3,513,433 | 2010-08-18T14:57:00.000 | 0 | 0 | 0 | 0 | python,sqlalchemy | 3,513,490 | 1 | false | 1 | 0 | You must load the parent object again. | 1 | 0 | 0 | I'd like to query the database and get read-only objects with session object. I need to save the objects in my server and use them through the user session. If I use a object outside of the function that calls the database, I get this error:
"DetachedInstanceError: Parent instance is not bound to a Session; lazy load operation of attribute 'items' cannot proceed"
I don't need to make any change in those objects, so I don't need to load them again.
Is there any way that I can get that?
Thanks in advance! | How to get read-only objects from database? | 0 | 1 | 0 | 244 |
3,514,444 | 2010-08-18T16:41:00.000 | 2 | 0 | 1 | 0 | python,windows,version,uninstallation | 3,514,562 | 1 | true | 0 | 0 | Most python installations come with an uninstaller that shows up in Add/Remove programs on Windows.
It is certainly possible to have several versions installed. On my windows machine, I have Python 2.5, 2.6, 2.7 and 3.1. The "default" python is the one which occurs first in your system path. Also (depending on which installer you used), you may have to change the handler for .py files in the registry. If you want to run a particular version, then start python.exe from the appropriate directory (C:\Python26\python.exe).
Managing packages should be pretty easy too. EXE packages are generally tied to the python version. PIL, for example has installers like PIL-1.1.7.win32-py2.5.exe for Python 2.5 and PIL-1.1.7.win32-py2.6.exe for Python 2.6. Other packages can be dropped into the right site-packages folder. | 1 | 1 | 0 | After a fresh installation of my Windows dev machine, I installed Python 2.7.
Quickly I learnt that this was a mistake as many of the packages I use only work on Python 2.6. So I installed 2.6 also and now I have both installations.
How can I make everything work with Python 2.6 instead of Python 2.7?
Every time I install a package it installs into Python 2.7. Every time I run a .py file it runs using the 2.7 interpreter.
Is there a way to completely uninstall Python 2.7? | How to work with a new Python installation while having an old one installed? | 1.2 | 0 | 0 | 1,546 |
3,514,495 | 2010-08-18T16:46:00.000 | -2 | 1 | 1 | 0 | python,python-c-extension | 3,514,728 | 5 | false | 0 | 0 | multiprocessing is easy. if thats not fast enough, your question is complicated. | 1 | 12 | 0 | I want to run a cpu intensive program in Python across multiple cores and am trying to figure out how to write C extensions to do this. Are there any code samples or tutorials on this? | How to use C extensions in python to get around GIL | -0.07983 | 0 | 0 | 6,155 |
3,515,043 | 2010-08-18T17:51:00.000 | 3 | 0 | 1 | 0 | python | 3,516,882 | 5 | false | 0 | 0 | If you can't install anything on the computer, the you might be best off outputting an HTML file with the data in a <table> that the user could view/search/print in IE. | 2 | 1 | 0 | I have an executable (converted to exe from python using py2exe) that outputs lists of numbers that could be from 0-50K lines long or a little bit more.
While developing, I just saved them to a TXT file using simple f.write.
The person wants to print this output on paper! (don't ask why lol)
So, I'm wondering if I can output it to something like HTML? XML? Something that could display tables of 50K lines and maybe 3 columns and that would also run in any PC without additional programs?
Suggestions?
EDIT:
Regarding CSV:
In most situations the best way in my opinion would be to make a CSV. I'm not opposing it in anyway, rather I think others might find Lott's answer useful for their cases. Sorry I didn't explain it that well in my question as far as my constraints go.
My constraints are: the user doesn't have an office suite, no python installed. Just think of a PC that has the bare minimum after a clean windows xp/vista installation, maybe Internet Explorer 7 or 8. This PC has to be able to open my output file and allow for reasonable viewing, searching, and printing. | Which format should I save my python script output? | 0.119427 | 0 | 0 | 648 |
3,515,043 | 2010-08-18T17:51:00.000 | 1 | 0 | 1 | 0 | python | 3,515,070 | 5 | false | 0 | 0 | You could use LaTeX to produce a PDF, maybe? But why exactly isn't a text file good enough? | 2 | 1 | 0 | I have an executable (converted to exe from python using py2exe) that outputs lists of numbers that could be from 0-50K lines long or a little bit more.
While developing, I just saved them to a TXT file using simple f.write.
The person wants to print this output on paper! (don't ask why lol)
So, I'm wondering if I can output it to something like HTML? XML? Something that could display tables of 50K lines and maybe 3 columns and that would also run in any PC without additional programs?
Suggestions?
EDIT:
Regarding CSV:
In most situations the best way in my opinion would be to make a CSV. I'm not opposing it in anyway, rather I think others might find Lott's answer useful for their cases. Sorry I didn't explain it that well in my question as far as my constraints go.
My constraints are: the user doesn't have an office suite, no python installed. Just think of a PC that has the bare minimum after a clean windows xp/vista installation, maybe Internet Explorer 7 or 8. This PC has to be able to open my output file and allow for reasonable viewing, searching, and printing. | Which format should I save my python script output? | 0.039979 | 0 | 0 | 648 |
3,515,673 | 2010-08-18T18:59:00.000 | 26 | 0 | 1 | 1 | python,installation,uninstallation | 60,318,668 | 14 | false | 0 | 0 | you can delete it manually.
open Command Prompt
cd C:\Users\<you name>\AppData\Local\Microsoft\WindowsApps
del python.exe
del python3.exe
Now the command prompt won't be showing it anymore
where python --> yields nothing, and you are free to install another version from source / anaconda and (after adding its address to Environment Variables -> Path) you will find that very python you just installed | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 1 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 8 | 0 | 1 | 1 | python,installation,uninstallation | 38,920,189 | 14 | false | 0 | 0 | I had window 7 (64 bit) and Python 2.7.12,
I uninstalled it by clicking the python installer from the "download" directory then I selected remove python then I clicked “ finish”.
I also removed the remaining python associated directory & files from the c: drive and also from “my documents” folder, since I created some files there. | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 1 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 56 | 0 | 1 | 1 | python,installation,uninstallation | 18,430,403 | 14 | false | 0 | 0 | Here's the steps (my non-computer-savvy girlfriend had to figure this one out for me, but unlike all the far more complicated processes one can find online, this one works)
Open Control Panel
Click "Uninstall a Program"
Scroll down to Python and click uninstall for each version you don't want anymore.
This works on Windows 7 out of the box, no additional programs or scripts required. | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 1 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 3 | 0 | 1 | 1 | python,installation,uninstallation | 68,139,862 | 14 | false | 0 | 0 | Open CMD
To show all packages installed - pip list
To copy the packages name to a file - pip freeze > requirements.txt
To delete all packages - pip uninstall -r requirements.txt -y
Check all packages are removed - pip list
Uninstall pip and other remaining packages
Control panel > Uninstall > Python uninstall (from UI) | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.042831 | 0 | 0 | 600,614 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.