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,329,762 | 2010-07-25T15:30:00.000 | 1 | 0 | 0 | 0 | python,wxpython,wxwidgets | 3,330,832 | 3 | false | 0 | 1 | afaik... none. I'll follow the answers to see if someone has one and try it of course but I'm not convinced this will be THAT useful. When using wxPython, you usually work with sizers (at least I think the results are better) so you don't really need to "place" the controls on the frame and I think a GUI "design" would be longer to do. The only part where I think it could have some interest is to fill atributes for the controls but a good auto-complete with wx (or a good cheat sheet or a "template class" with all the options you use) solves the problem in my opinion. I stopped seeking for a GUI designer for wx after trying Pydev that auto-completes wx very nicely (a lot better than everything I tried before... and that's a lot!). | 2 | 2 | 0 | What are the usable tools?
I am aware of wxformbuilder and wxGlade, but none of them seems to be complete yet. | What are the existing open-source Python WxWidgets designers? | 0.066568 | 0 | 0 | 831 |
3,329,775 | 2010-07-25T15:35:00.000 | 10 | 1 | 1 | 0 | python,syntax | 3,329,797 | 4 | true | 0 | 0 | It's an old control character from typewriters.
It means "carriage return". In this time, when you pressed "enter", you were going to the next line, then the carriage went back to the beginning of the line (hence the carriage return).
Then with computers, different OSes made different choices to represent new lines.
On windows, you have "\r\n" (carriage return + new line).
On unices, you have "\n" only (no need to do a carriage return, it was sort of implied by the new line).
On old mac OS, you had "\r" only.
Nowadays, it's not used except for newlines (or I don't know other usages). | 1 | 3 | 0 | What does '\r' mean? What does it do? I have never seen it before and its giving me headaches. It doesnt seem to have any purpose, since 'a\ra' prints as 'aa', but its not the same as the string 'aa'. Im using python 2.6 | What does this stand for? | 1.2 | 0 | 0 | 11,032 |
3,330,643 | 2010-07-25T19:16:00.000 | 2 | 0 | 1 | 0 | python,osx-snow-leopard,memory-management,x86-64,i386 | 3,330,648 | 2 | false | 0 | 0 | No, it's physically impossible. That doesn't stop the OS assigning more than it can use due to alignment and fragmentation, say, it could have a whole page and not actually map in all of it. However it's impossible to actually use over 4GB for any process, and most likely substantially less than that for kernel space. | 2 | 3 | 0 | Is it possible for a single process running a 32-bit compiled version of python in Snow Leopard (64-bit machine) to appear to consume > 4GB (say 5.4GB) of virtual memory as seen by the top command?
I did a file ...python to see that the binary was not x86, yet it appeared to be consuming over 5GB of memory.
My guess is that the libraries that were used (RPy) were 'mmap'ing chunks of data, and the in-memory cache was appearing under the memory footprint of my process.
Or maybe I haven't verified that the Python binaries were 32-bit. Or maybe there's some 32-bit/64-bit commingling going (libffi?).
Totally confused. | Can a process running a 32-bit compiled binary use more than 4GB of memory? | 0.197375 | 0 | 0 | 307 |
3,330,643 | 2010-07-25T19:16:00.000 | 1 | 0 | 1 | 0 | python,osx-snow-leopard,memory-management,x86-64,i386 | 3,347,445 | 2 | false | 0 | 0 | It is possible if the processes is using some kind of insane long/far/extended pointers and mapping data into and outof a 32-bit address space as it needs it, but at that point it hardly qualifies as 32-bit anyway. (Python most definitely does not do this, so @DeadMG's answer is almost certainly what is actually happening.) | 2 | 3 | 0 | Is it possible for a single process running a 32-bit compiled version of python in Snow Leopard (64-bit machine) to appear to consume > 4GB (say 5.4GB) of virtual memory as seen by the top command?
I did a file ...python to see that the binary was not x86, yet it appeared to be consuming over 5GB of memory.
My guess is that the libraries that were used (RPy) were 'mmap'ing chunks of data, and the in-memory cache was appearing under the memory footprint of my process.
Or maybe I haven't verified that the Python binaries were 32-bit. Or maybe there's some 32-bit/64-bit commingling going (libffi?).
Totally confused. | Can a process running a 32-bit compiled binary use more than 4GB of memory? | 0.099668 | 0 | 0 | 307 |
3,330,668 | 2010-07-25T19:23:00.000 | 1 | 0 | 1 | 0 | python,parsing,list,sorting,dictionary | 3,333,193 | 3 | false | 0 | 0 | Are you loading all the data into memory at once? If so you could be causing the OS to swap memory to disk, which can bring any system to a crawl. Dictionaries are hashtables so even an empty dict will use up a lot of memory, and from what you say you are creating a lot of them at once. I don't know the MongoDB API, but I presume there is a way of iterating through the results one at a time instead of reading in the entire set of result at once - try using that. Or rewrite your query to return a subset of the data.
If disk swapping is not the problem then profile the code to see what the bottleneck is, or put some sample code in your question. Without more specific information it is hard to give a more specific answer. | 2 | 0 | 0 | I'm using MongoDB an nosql database. Basically as a result of a query I have a list of dicts which themselves contains lists of dictionaries... which I need to work with.
Unfortunately dealing with all this data within Python can be brought to a crawl when the data is too much.
I have never had to deal with this problem, and it would be great if someone with experience could give a few suggestions. =) | Speeding up parsing of HUGE lists of dictionaries - Python | 0.066568 | 1 | 0 | 406 |
3,330,668 | 2010-07-25T19:23:00.000 | 3 | 0 | 1 | 0 | python,parsing,list,sorting,dictionary | 3,333,236 | 3 | true | 0 | 0 | Do you really want all of that data back in your Python program? If so fetch it back a little at a time, but if all you want to do is summarise the data then use mapreduce in MongoDB to distribute the processing and just return the summarised data.
After all, the point about using a NoSQL database that cleanly shards all the data across multiple machines is precisely to avoid having to pull it all back onto a single machine for processing. | 2 | 0 | 0 | I'm using MongoDB an nosql database. Basically as a result of a query I have a list of dicts which themselves contains lists of dictionaries... which I need to work with.
Unfortunately dealing with all this data within Python can be brought to a crawl when the data is too much.
I have never had to deal with this problem, and it would be great if someone with experience could give a few suggestions. =) | Speeding up parsing of HUGE lists of dictionaries - Python | 1.2 | 1 | 0 | 406 |
3,330,983 | 2010-07-25T20:59:00.000 | 5 | 0 | 0 | 0 | python,ironpython | 3,331,020 | 5 | true | 0 | 0 | IronPython doesn't have an alternate syntax. It's an implementation of Python, and Python uses significant indentation (all languages use significant whitespace, not sure why we talk about whitespace when it's only indentation that's unusual in the Python case). | 1 | 0 | 0 | For rapidly changing business rules, I'm storing IronPython fragments in XML files. So far this has been working out well, but I'm starting to get to the point where I need more that just one-line expressions.
The problem is that XML and significant whilespace don't play well together. Before I abandon it for another language, I would like to know if IronPython has an alternative syntax. | IronPython: Is there an alternative to significant whitespace? | 1.2 | 0 | 0 | 427 |
3,331,027 | 2010-07-25T21:13:00.000 | 6 | 1 | 0 | 1 | python,tcl,irc,node.js,eggdrop | 3,331,115 | 2 | true | 0 | 0 | As you suspected, eggdrop is not written in tcl, it is written in C, however it does use tcl as its scripting/extension language.
I would expect that in the case of an eggdrop, the performance difference between using tcl as a scripting language, and using Python, Lua, JS, or virtually anything else would be negligible, as eggdrops generally aren't performing high load tasks.
In the event it really was an issue, your question would need more specifics. Performance for what task under what conditions? Memory use? CPU efficiency? Latency? And the answer would probably be "measure and find out". Given the typical use of an eggdrop, it doesn't take particularly efficient code to respond to the occasional IRC trigger command once every few minutes or hours.
As a more general case, I'm sure you could find benchmark comparisons of specific algorithms or tasks performed by various scripting languages on particular operating systems or environments, at which point it wouldn't really have anything to do with IRC or eggdrop. | 1 | 3 | 0 | I believe eggdrop is the most active/popular bot and it's written in tcl ( and according to wiki the core is C but I haven't confirmed that ).
I'm wondering if there would be any performance benefit of recoding it's functionality in node.js or Python, in addition to making it more accessible since Python and JS are arguably more popular languages and not many are familiar with tcl.
So, how would they stack up vs tcl in general, performance-wise? | How would an irc bot written in tcl stack up against a python/node.js clone? | 1.2 | 0 | 0 | 964 |
3,332,263 | 2010-07-26T04:48:00.000 | 0 | 0 | 0 | 0 | user-interface,wxpython,real-time | 5,598,605 | 1 | false | 0 | 1 | If you can connect to this mysterious device and receive data from it from Python, then you can display said data with wxPython or any other GUI toolkit. You don't really say what kind of data it is or what you want to display? Lines? Graphs? Or what? If it's just tabular data, use the wx.ListCtrl (or ObjectListView) widget. If you need graphs, see the Plot widget or Matplotlib. | 1 | 0 | 0 | I am new to this post as well as to python GUI programming.I want to make a realtime graphical GUI in wxpython.My requirement is that i have to catch signals from a device and i have to display the data in graphical as well as in textual form.The system should be accurate and be specific with the time constraints.Please can any one guide me in this,and if this be possible in wxpython and if yes how can i and if no what i can use for this is python.
Hoping someone will help me out soon.Thanks in advance and for your concern.
regards,
Anil ph | Help : Realtime graphical interface in wxpython | 0 | 0 | 0 | 179 |
3,332,494 | 2010-07-26T05:59:00.000 | 1 | 0 | 0 | 0 | python,html,string,templates,parsing | 3,332,528 | 3 | false | 1 | 0 | It's very hard to come up with a rule that works 100% of the time, obviously, but my suggestion as a starting point would be to look for the first <h1> tag (or <h2>, <h3>, etc - the highest one you can find) then the bit of text after that can be used as the description. As long as the site is semantically marked-up, that should give you a good description (I guess you could also take the contents of the <h1> itself, but that's more like the "title").
It's interesting to note that Google (for example) uses a keyword-specific extract of the page contents to display as the description, rather than a static description. Not sure if that'll work for your situation, though. | 1 | 6 | 0 | Suppose I downloaded the HTML code, and I can parse it.
How do I get the "best" description of that website, if that website does not have meta-description tag? | What's the best way to get a description of the website, in Python? | 0.066568 | 0 | 1 | 519 |
3,332,897 | 2010-07-26T07:14:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine,parsing | 3,334,425 | 1 | false | 1 | 0 | The 1MB limit doesn't apply to parsing; however, you can't fetch more than 1MB from URLfetch; you'll only get the first 1MB from the API.
It's probably not going to be possible to get the XML into your application using the URLfetch API. If the data is smaller than 10MB, you can arrange for an external process to POST it to your application and then process it. If it's between 10MB and 2GB, you'd need to use the Blobstore API to upload it, read it in to your application in 1MB chunks, and process the concatenation of those chunks. | 1 | 1 | 0 | Hi i need to parse xml file which is more then 1 mb in size, i know GAE can handle request and response up to 10 MB but as we need to use SAX parser API and API GAE has limit of 1 MB so is there way we can parse file more then 1 mb any ways. | Google app engine parsing xml more then 1 mb | 0.379949 | 0 | 1 | 485 |
3,333,095 | 2010-07-26T07:54:00.000 | 6 | 0 | 1 | 0 | python,build,linker,sqlite | 3,341,117 | 3 | false | 0 | 0 | download the latest version of sqlite3.dll from sqlite website and replace the the sqlite3.dll in the python dir. | 2 | 9 | 0 | I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.
I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.
So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--
How would I do this?
I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system | How can I upgrade the sqlite3 package in Python 2.6? | 1 | 1 | 0 | 4,281 |
3,333,095 | 2010-07-26T07:54:00.000 | 1 | 0 | 1 | 0 | python,build,linker,sqlite | 3,333,348 | 3 | false | 0 | 0 | I decided I'd just give this a shot when I realized that every library I've ever installed in python 2.6 resided in my site-packages folder. I just... copied site-packages to my 2.7 installation, and it works so far. This is by far the easiest route for me if this works -- I'll look further into it but at least I can continue to develop now.
I won't accept this answer, because it doesn't even answer my question, but it does solve my problem, as far as I can tell so far. | 2 | 9 | 0 | I was using Python 2.6.5 to build my application, which came with sqlite3 3.5.9. Apparently though, as I found out in another question of mine, foreign key support wasn't introduced in sqlite3 until version 3.6.19. However, Python 2.7 comes with sqlite3 3.6.21, so this work -- I decided I wanted to use foreign keys in my application, so I tried upgrading to python 2.7.
I'm using twisted, and I couldn't for the life of me get it to build. Twisted relies on zope.interface and I can't find zope.interface for python 2.7 -- I thought it might just "work" anyway, but I'd have to just copy all the files over myself, and get everything working myself, rather than just using the self-installing packages.
So I thought it might be wiser to just re-build python 2.6 and link it against a new version of sqlite3. But I don't know how--
How would I do this?
I have Visual Studio 2008 installed as a compiler, I read that that is the only one that is really supported for Windows, and I am running a 64 bit operating system | How can I upgrade the sqlite3 package in Python 2.6? | 0.066568 | 1 | 0 | 4,281 |
3,333,113 | 2010-07-26T07:57:00.000 | 0 | 1 | 0 | 1 | python,web-services,pylons | 3,358,288 | 2 | false | 0 | 0 | I'm using Nginx (with fastcgi) or Apache for hosting Pylons sites, mostly because lack of some "production" features in Paste, but for development Paste is very usefull and handy. | 1 | 5 | 0 | I'm looking into Pylons and was wondering, should I use Paste as the webserver or can I use Apache?
Are there advantages to using Paste?
Would you recommend against using Apache?
How should I host the sites? | Should I use Pylon's Paste to host my Pylons website? Or can I use Apache? | 0 | 0 | 0 | 511 |
3,333,929 | 2010-07-26T10:16:00.000 | -2 | 0 | 0 | 0 | python,networking,ftplib | 68,453,582 | 2 | false | 0 | 0 | Since Python 3.3, ftplib functions that establish connections take a source_addr argument that allows you to do exactly this. | 1 | 0 | 0 | I use python ftplib to connect to a ftp server which is running on active mode; That means the server will connect my client machine on a random port when data is sent between us.
Considering security issue, Can I specify the client's data port (or port range) and let the server connect the certain port?
Many Thanks for your response. | How can I specify the client's data port for a ftp server in active mode? | -0.197375 | 0 | 1 | 1,268 |
3,334,777 | 2010-07-26T12:31:00.000 | 1 | 0 | 0 | 0 | python,django,long-polling,gevent | 3,338,935 | 3 | true | 0 | 0 | This depends on which WSGI server you use. AFAIK gevent.wsgi will not notify your handler in any way when the client closes the connection, because libevent-http does not do that. However, with gevent.pywsgi it should be possible. You'll probably need to start an additional greenlet to monitor the socket condition and somehow notify the greenlet that runs the handler, e.g. by killing it. I could be missing an easier way to do this though. | 1 | 7 | 0 | I'm using long polling for a chat with gevent. I'm using Event.wait() when waiting for new messages to be posted on the chat.
I would like to handle the occasion a client disconnects with some functionality:
e.g. Return "client has disconnected" as a message for other chat users
Is this possible? =) | Capturing event of client disconnecting! - Gevent/Python | 1.2 | 0 | 1 | 1,701 |
3,336,457 | 2010-07-26T15:42:00.000 | 0 | 0 | 0 | 0 | python,multithreading,pygtk,wrapper | 3,337,085 | 2 | true | 0 | 1 | Turns out the problem was that I couldn't find a working solution because I was utilizing the Thread module the wrong way and calling run() directly when I should have been calling start(). Because of that, I was thinking that nothing I did worked (especially with no error or complaint from anything) and figured it was a problem relating to how I was wrapping gtk.main() | 2 | 0 | 0 | I have an application where my DataFetch() class "Wraps" around my HBHTray() class for the purpose of interacting with the functions/variables of that class. Unfortunately, I can't seem to be able to get the code to continue execution after my DataFetch() class makes a instance of HBHTray and calls it, and on the Start() method of HBHTray it hangs.
This is the relevant code:
class DataFetch(): # I need the DataFetch class to be wrapping around HBHTray so I can call/edit certain variables from within functions in DataFetch
def init(self):
self.Interval, self.Username, self.Password, self.CheckShoutBox = GetOptions('.tray')
self.Gui = HBHTray()
print '1'
self.Gui.Start()
print '2'
def Login(self):
pass # Do stuff (Eg: Edit self.Gui.StatusIcon state or call self.Gui.Notify()
def Start(self):
print 'hi!'
sleep(self.Interval)
print 'Hi!'
class HBHTray():
def init(self):
self.StatusIcon = gtk.StatusIcon()
self.StatusIcon.set_from_file('img')
self.StatusIcon.set_tooltip('No new messages')
self.Menu = gtk.Menu()
self.CheckBox = gtk.CheckMenuItem('Notify')
self.CheckBox.connect('activate', self.ChangeCheckBox)
self.CheckBox.set_active(True)
self.Menu.append(self.CheckBox)
self.MenuItem = gtk.ImageMenuItem('Options')
self.MenuItem.connect('activate', self.Options, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.MenuItem = gtk.ImageMenuItem('About')
self.MenuItem.connect('activate', self.About, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.MenuItem = gtk.ImageMenuItem('Quit')
self.MenuItem.connect('activate', self.Quit, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.StatusIcon.connect('popup-menu', self.PopMenu, self.Menu)
self.StatusIcon.set_visible(1)
def PopMenu(self, widget, button, time, data = None):
if data:
data.show_all()
data.popup(None, None, gtk.status_icon_position_menu, 3, time, self.StatusIcon)
def Notify(self, message):
pynotify.init('null')
notification = pynotify.Notification('Something', message, 'dialogue')
notification.attach_to_status_icon(self.StatusIcon)
notification.show()
def Start(self):
gtk.main()
def About(self, a, b):
self.Notify('test')
def Options(self, a, b):
print a, b
def ChangeCheckBox(self, null):
pass
def Quit(self, a, b):
raise SystemExit
if name == 'main':
try:
gobject.threads_init() # Doesn't work?
Monitor = DataFetch()
Monitor.Start()
Sorry for the terrible formatting, Stack Overflow doesn't seem to like blank lines....
Anyways, though, "1" is printed, but "2" is not. So, gtk.main() is obviously where it's hanging. Is there any way to allow me to continue execution and have gtk go do it's own thing? | Continuing code execution after a pygtk.main() in python | 1.2 | 0 | 0 | 356 |
3,336,457 | 2010-07-26T15:42:00.000 | 0 | 0 | 0 | 0 | python,multithreading,pygtk,wrapper | 3,336,490 | 2 | false | 0 | 1 | gobject.threads_init() does not magically put your things into separate threads. It only tells the library that you're going to use threads, and sets up some locking. You'll still have to create the threads yourself. | 2 | 0 | 0 | I have an application where my DataFetch() class "Wraps" around my HBHTray() class for the purpose of interacting with the functions/variables of that class. Unfortunately, I can't seem to be able to get the code to continue execution after my DataFetch() class makes a instance of HBHTray and calls it, and on the Start() method of HBHTray it hangs.
This is the relevant code:
class DataFetch(): # I need the DataFetch class to be wrapping around HBHTray so I can call/edit certain variables from within functions in DataFetch
def init(self):
self.Interval, self.Username, self.Password, self.CheckShoutBox = GetOptions('.tray')
self.Gui = HBHTray()
print '1'
self.Gui.Start()
print '2'
def Login(self):
pass # Do stuff (Eg: Edit self.Gui.StatusIcon state or call self.Gui.Notify()
def Start(self):
print 'hi!'
sleep(self.Interval)
print 'Hi!'
class HBHTray():
def init(self):
self.StatusIcon = gtk.StatusIcon()
self.StatusIcon.set_from_file('img')
self.StatusIcon.set_tooltip('No new messages')
self.Menu = gtk.Menu()
self.CheckBox = gtk.CheckMenuItem('Notify')
self.CheckBox.connect('activate', self.ChangeCheckBox)
self.CheckBox.set_active(True)
self.Menu.append(self.CheckBox)
self.MenuItem = gtk.ImageMenuItem('Options')
self.MenuItem.connect('activate', self.Options, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.MenuItem = gtk.ImageMenuItem('About')
self.MenuItem.connect('activate', self.About, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.MenuItem = gtk.ImageMenuItem('Quit')
self.MenuItem.connect('activate', self.Quit, self.StatusIcon)
self.Menu.append(self.MenuItem)
self.StatusIcon.connect('popup-menu', self.PopMenu, self.Menu)
self.StatusIcon.set_visible(1)
def PopMenu(self, widget, button, time, data = None):
if data:
data.show_all()
data.popup(None, None, gtk.status_icon_position_menu, 3, time, self.StatusIcon)
def Notify(self, message):
pynotify.init('null')
notification = pynotify.Notification('Something', message, 'dialogue')
notification.attach_to_status_icon(self.StatusIcon)
notification.show()
def Start(self):
gtk.main()
def About(self, a, b):
self.Notify('test')
def Options(self, a, b):
print a, b
def ChangeCheckBox(self, null):
pass
def Quit(self, a, b):
raise SystemExit
if name == 'main':
try:
gobject.threads_init() # Doesn't work?
Monitor = DataFetch()
Monitor.Start()
Sorry for the terrible formatting, Stack Overflow doesn't seem to like blank lines....
Anyways, though, "1" is printed, but "2" is not. So, gtk.main() is obviously where it's hanging. Is there any way to allow me to continue execution and have gtk go do it's own thing? | Continuing code execution after a pygtk.main() in python | 0 | 0 | 0 | 356 |
3,336,787 | 2010-07-26T16:21:00.000 | 4 | 1 | 0 | 0 | python,webserver,mod-wsgi | 3,339,594 | 6 | false | 1 | 0 | Don't get carried away with trying to work out what is the fastest web server. All you will do in doing that is waste your time. This is because the web server is nearly never the bottleneck if you set them up properly. The real bottleneck is your web application, database access etc.
As such, choose whatever web hosting system you think meets your general requirements and which you find easy to setup and manage. Using something you understand and which doesn't require lots of time devoted to it, means you can then focus your valuable time on making your application perform better, thus reducing the real bottleneck. | 2 | 2 | 0 | I am leasing a dedicated web server.
I have a Python web-application.
Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?
UPDATE:
Note, I'm not using a Python framework such as Django or Pylons. | Python/Web: What's the best way to run Python on a web server? | 0.132549 | 0 | 0 | 5,769 |
3,336,787 | 2010-07-26T16:21:00.000 | -1 | 1 | 0 | 0 | python,webserver,mod-wsgi | 3,336,816 | 6 | false | 1 | 0 | You don't usually just serve Python, you serve a specific web server or framework based on Python. eg. Zope, TurboGears, Django, Pylons, etc. Although they tend to be able to operate on different web server back-ends (and some provide an internal web server themselves), the best solution will depend on which one you use. | 2 | 2 | 0 | I am leasing a dedicated web server.
I have a Python web-application.
Which configuration option (CGI, FCGI, mod_python, Passenger, etc) would result in Python being served the fastest on my web server and how do I set it up that way?
UPDATE:
Note, I'm not using a Python framework such as Django or Pylons. | Python/Web: What's the best way to run Python on a web server? | -0.033321 | 0 | 0 | 5,769 |
3,337,301 | 2010-07-26T17:25:00.000 | 2 | 0 | 0 | 0 | python,arrays,matrix,numpy | 32,098,823 | 10 | false | 0 | 0 | First, Mv = numpy.asarray(M.T), which gives you a 4x1 but 2D array.
Then, perform A = Mv[0,:], which gives you what you want. You could put them together, as numpy.asarray(M.T)[0,:]. | 1 | 184 | 1 | I am using numpy. I have a matrix with 1 column and N rows and I want to get an array from with N elements.
For example, if i have M = matrix([[1], [2], [3], [4]]), I want to get A = array([1,2,3,4]).
To achieve it, I use A = np.array(M.T)[0]. Does anyone know a more elegant way to get the same result?
Thanks! | Numpy matrix to array | 0.039979 | 0 | 0 | 319,127 |
3,337,725 | 2010-07-26T18:19:00.000 | 5 | 0 | 1 | 0 | python,user-interface,ironpython,jython,cpython | 3,337,830 | 8 | false | 0 | 1 | Well, Mono does not come with the base of most Linux distributions. It's not a terribly lightweight dependency either, and I think Java is considerably more likely for people to already have. Would you plan on using "Winforms" with Mono? If so, and you don't have experience with Winforms, read about what others have to say :-) The other .NET GUI toolkit is WPF, which unfortunately Mono has no plans to implement.
Jython would be better too, because you can use SWT, which renders native widgets and provides lots of layout possibilities easily. Or you can use Jython with Swing, or whatever else -- even AWT if you love ugliness.
I really like wxPython (which you can use with CPython, which is on most distros by default), because it renders good-looking native widgets in OSX, Windows and Linux (I've only seen the Gnome widgets in person). wxPython is by far the easiest to use GUI toolkit I've used -- even programatically (i.e. layout without Glade or similar). I've also used SWT, which I found quite nice, and Swing, which I personally don't really like the looks of, and Winforms, which was a nightmare to try to do even simple layouts with.
Here's a quick comparison of the existence of the interpreter/language runtime by OS
CPython
Windows - Probably not installed, and you'd have to make a non-python installer install it with your software :-P
Linux - Probably installed (Ubuntu, Gentoo and RedHat all have system tools that are written in Python and run on CPython)
Mac - Preinstalled on OSX
Jython
Windows - Probably installed at some point in my experience, though it doesn't come with
Linux - Probably installed, but more importantly nobody would hate you for depending on it like Mono
Mac - Preinstalled on OSX ("Mac OS X Leopard comes with J2SE 5.0 preinstalled, based on JDK 1.5.0_13_b05" -- Apple's site)
IronPython
Windows - Will probably run fine because I bet most people have at the very least .NET 2.0 if they have a recent version of Windows
Linux - Probably not installed -- the only application with which I've used Mono on Linux was Rasterbator, which worked well but I felt weird putting .NET on Linux
Mac - See above
I would choose a GUI toolkit first, since that will very much impact the user experience and overall difficulty (I would choose wxPython but SWT would be a close second) then consider the above as well maybe as a tiebreaker. | 5 | 9 | 0 | I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.
I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.
My goals:
1. to make GUI using as less custom components as possible.
2. to make it as cross-platform as possible
(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)
So - the question is about GUI - what should I choose? | CPython vs. Jython vs. IronPython for cross-platform GUI development | 0.124353 | 0 | 0 | 6,247 |
3,337,725 | 2010-07-26T18:19:00.000 | 2 | 0 | 1 | 0 | python,user-interface,ironpython,jython,cpython | 3,337,760 | 8 | false | 0 | 1 | Take a look at comparable GUI's written in python/jython/ironpython. Look for programs that you like and find out what they use. I guess most if not all will be written in cpython + gtk or cpython + qt. I think all gui toolkits in python are cross platform. | 5 | 9 | 0 | I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.
I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.
My goals:
1. to make GUI using as less custom components as possible.
2. to make it as cross-platform as possible
(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)
So - the question is about GUI - what should I choose? | CPython vs. Jython vs. IronPython for cross-platform GUI development | 0.049958 | 0 | 0 | 6,247 |
3,337,725 | 2010-07-26T18:19:00.000 | 5 | 0 | 1 | 0 | python,user-interface,ironpython,jython,cpython | 3,337,744 | 8 | false | 0 | 1 | I'd say that if cross-platform is a goal, forget IronPython. A lot of people hate the dependency hell it causes so it'll be too much work to get it up in running in some OSes/distributions. Jython will suffer this also, albeit to a lesser degree. | 5 | 9 | 0 | I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.
I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.
My goals:
1. to make GUI using as less custom components as possible.
2. to make it as cross-platform as possible
(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)
So - the question is about GUI - what should I choose? | CPython vs. Jython vs. IronPython for cross-platform GUI development | 0.124353 | 0 | 0 | 6,247 |
3,337,725 | 2010-07-26T18:19:00.000 | 2 | 0 | 1 | 0 | python,user-interface,ironpython,jython,cpython | 3,341,283 | 8 | false | 0 | 1 | Java is the most portable platform. Jython is written in 100% pure Java. 'Nuff said.
BTW I just switched a CPython/GTK project to Jython (trying to remove as much unmanaged code as possible), the only problem is that Jython is at 2.5 still, which kind of sucks when you're used to 2.6/2.7/3 :) | 5 | 9 | 0 | I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.
I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.
My goals:
1. to make GUI using as less custom components as possible.
2. to make it as cross-platform as possible
(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)
So - the question is about GUI - what should I choose? | CPython vs. Jython vs. IronPython for cross-platform GUI development | 0.049958 | 0 | 0 | 6,247 |
3,337,725 | 2010-07-26T18:19:00.000 | 1 | 0 | 1 | 0 | python,user-interface,ironpython,jython,cpython | 3,337,836 | 8 | false | 0 | 1 | There are plenty of answers already, but I'd like to add one important thing - regardless of which library you learn, most of the principles will be the same when you move to another library.
I don't know about Qt, but for most graphics programs (in PyGTK or Tkinter) the best thing to do, as far as editing goes, is to use a PIL image (or something similar) to draw on and then draw that image on your canvas widget, otherwise you can lose pixel data if your window gets covered. | 5 | 9 | 0 | I'm thinking of making some kind of experimental IDE for digital hardware design. So I can't decide witch platform to choose.
I'm going to have text-editor with syntax highlighting, some vector graphics and lots of tabbed windows.
My goals:
1. to make GUI using as less custom components as possible.
2. to make it as cross-platform as possible
(I know already that CPython and Jython are cross-platform-friendly, but what about IronPython+Mono?)
So - the question is about GUI - what should I choose? | CPython vs. Jython vs. IronPython for cross-platform GUI development | 0.024995 | 0 | 0 | 6,247 |
3,337,973 | 2010-07-26T18:52:00.000 | 0 | 0 | 1 | 0 | python,keyboard,wxpython,hotkeys,keyboard-shortcuts | 3,345,475 | 4 | false | 0 | 0 | If you want hotkeys in your wxPython program (which I assume you do because of the wxPython tag), then you should use a wx.AcceleratorTable. | 1 | 11 | 0 | I wanna setup a global hotkey in python 2.6 that listens to the keyboard shortcut ctrl + D or ctrl+ alt+ D on windows, please help me | Set global hotkey with Python 2.6 | 0 | 0 | 0 | 13,435 |
3,338,616 | 2010-07-26T20:13:00.000 | 5 | 0 | 1 | 1 | python,linux,centos | 3,338,914 | 7 | false | 0 | 0 | One of the problems with system() is that it implies knowledge of the shell's syntax and language for parsing and executing your command line. This creates potential for a bug where you didn't validate input properly, and the shell might interpet something like variable substitution or determining where an argument begins or ends in a way you don't expect. Also, another OS's shell might have divergent syntax from your own, including very subtle divergence that you won't notice right away. For reasons like these I prefer to use execve() instead of system() -- you can pass argv tokens directly and not have to worry about something in the middle (mis-)parsing your input.
Another problem with system() (this also applies to using execve()) is that when you code that, you are saying, "look for this program, and pass it these args". This makes a couple of assumptions which may lead to bugs. First is that the program exists and can be found in $PATH. Maybe on some system it won't. Second, maybe on some system, or even a future version of your own OS, it will support a different set of options. In this sense, I would avoid doing this unless you are absolutely certain the system you will run on will have the program. (Like maybe you put the callee program on the system to begin with, or the way you invoke it is mandated by something like POSIX.)
Lastly... There's also a performance hit associated with looking for the right program, creating a new process, loading the program, etc. If you are doing something simple like a mv, it's much more efficient to use the system call directly.
These are just a few of the reasons to avoid system(). Surely there are more. | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 0.141893 | 0 | 0 | 3,734 |
3,338,616 | 2010-07-26T20:13:00.000 | 3 | 0 | 1 | 1 | python,linux,centos | 3,338,752 | 7 | false | 0 | 0 | The only time that os.system might be appropriate is for a quick-and-dirty solution for a non-production script or some kind of testing. Otherwise, it is best to use built-in functions. | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 0.085505 | 0 | 0 | 3,734 |
3,338,616 | 2010-07-26T20:13:00.000 | 18 | 0 | 1 | 1 | python,linux,centos | 3,338,632 | 7 | true | 0 | 0 | Rule of thumb: if there's a built-in Python function to achieve this functionality use this function. Why? It makes your code portable across different systems, more secure and probably faster as there will be no need to spawn an additional process. | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 1.2 | 0 | 0 | 3,734 |
3,338,616 | 2010-07-26T20:13:00.000 | 4 | 0 | 1 | 1 | python,linux,centos | 3,338,678 | 7 | false | 0 | 0 | Darin's answer is a good start.
Beyond that, it's a matter of how portable you plan to be. If your program is only ever going to run on a reasonably "standard" and "modern" Linux then there's no reason for you to re-invent the wheel; if you tried to re-write make or xterm they'd be sending the men in the white coats for you. If it works and you don't have platform concerns, knock yourself out and simply use Python as glue!
If compatibility across unknown systems was a big deal you could try looking for libraries to do what you need done in a platform independent way. Or you need to look into a way to call on-board utilities with different names, paths and mechanisms depending on which kind of system you're on. | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 0.113791 | 0 | 0 | 3,734 |
3,338,616 | 2010-07-26T20:13:00.000 | 3 | 0 | 1 | 1 | python,linux,centos | 3,339,586 | 7 | false | 0 | 0 | Your question seems to have two parts. You mention calling commands like "xterm", "rm -rf", and "cd".
Side Note: you cannot call 'cd' in a sub-shell. I bet that was a trick question ...
As far as other command-level things you might want to do, like "rm -rf SOMETHING", there is already a python equivalent. This answers the first part of your question. But I suspect you are really asking about the second part.
The second part of your question can be rephrased as "should I use system() or something like the subprocess module?".
I have a simple answer for you: just say NO to using "system()", except for prototyping.
It's fine for verifying that something works, or for that "quick and dirty" script, but there are just too many problems with os.system():
It forks a shell for you -- fine if you need one
It expands wild cards for you -- fine unless you don't have any
It handles redirect -- fine if you want that
It dumps output to stderr/stdout and reads from stdin by default
It tries to understand quoting, but it doesn't do very well (try 'Cmd" > "Ofile')
Related to #5, it doesn't always grok argument boundaries (i.e. arguments with spaces in them might get screwed up)
Just say no to "system()"! | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 0.085505 | 0 | 0 | 3,734 |
3,338,616 | 2010-07-26T20:13:00.000 | 2 | 0 | 1 | 1 | python,linux,centos | 3,338,709 | 7 | false | 0 | 0 | I would suggest that you only use use os.system for things that there are not already equivalents for within the os module. Why make your life harder? | 6 | 12 | 0 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. | Python - When Is It Ok to Use os.system() to issue common Linux commands | 0.057081 | 0 | 0 | 3,734 |
3,339,263 | 2010-07-26T21:50:00.000 | 1 | 0 | 0 | 0 | python,wxpython,refresh | 3,339,765 | 2 | false | 0 | 1 | Call the SetLabel method in your static text instance. So you don't run into conflict with the size, make sure your StaticText instance is created with enough space to write the future labels you'll want to write to it. | 1 | 5 | 0 | i was wondering how to update a StaticText dynamically in wxpython?
I have a script that goes every five minutes and reads a status from a webpage, then prints using wxpython the status in a static input.
How would i dynamically, every 5 minutes update the statictext to reflect the status?
thanks alot
-soule | Dynamically update wxPython staticText | 0.099668 | 0 | 0 | 12,769 |
3,339,399 | 2010-07-26T22:14:00.000 | 18 | 0 | 1 | 0 | python,ide,intellij-idea,pycharm | 3,344,714 | 5 | true | 0 | 0 | Right now PyCharm is quite a bit farther ahead in terms of functionality compared to the Python plugin for IntelliJ IDEA 9. Once we start the EAP for IntelliJ IDEA 10, we'll also release a new version of the Python plugin containing all the latest features of PyCharm, but we don't currently plan to backport the new features to the IDEA 9 version of the plugin. So, if you're OK with using EAP builds of IntelliJ IDEA, you shouldn't need to buy a separate license for PyCharm. | 3 | 37 | 0 | So I have IntelliJ and love it, and have been using the Python plugin for a while. But I noticed that they have PyCharm coming out in beta now. I haven't been using PyCharm since I just use IntelliJ for everything, but is there a compelling reason to buy PyCharm? | Comparison of IntelliJ Python plugin or PyCharm | 1.2 | 0 | 0 | 23,201 |
3,339,399 | 2010-07-26T22:14:00.000 | -1 | 0 | 1 | 0 | python,ide,intellij-idea,pycharm | 3,339,453 | 5 | false | 0 | 0 | PyCharm supports django and Google App Engine. The django support is really nice if you use django. | 3 | 37 | 0 | So I have IntelliJ and love it, and have been using the Python plugin for a while. But I noticed that they have PyCharm coming out in beta now. I haven't been using PyCharm since I just use IntelliJ for everything, but is there a compelling reason to buy PyCharm? | Comparison of IntelliJ Python plugin or PyCharm | -0.039979 | 0 | 0 | 23,201 |
3,339,399 | 2010-07-26T22:14:00.000 | 2 | 0 | 1 | 0 | python,ide,intellij-idea,pycharm | 5,943,176 | 5 | false | 0 | 0 | Right now Pycharm does a much better job of detecting and automatically configuring itself to run existing Google App Engine apps. Using IntelliJ and the plugin requires quite a few steps to get an existing project to run.
In PyCharm all you really have to do is configure a run configuration
Script: /path/to/dev_appserver.py
Script Parameters: /path/to/your/app
Make sure you configure Python 2.5.x as your interpreter.
For comparison: In IntelliJ you need to first add a Python module to your project, then add Google App Engine to that perspective. None of that is at all obvious as you are trying to do it as IntelliJ will want to create new module directories rather than use your existing code. | 3 | 37 | 0 | So I have IntelliJ and love it, and have been using the Python plugin for a while. But I noticed that they have PyCharm coming out in beta now. I haven't been using PyCharm since I just use IntelliJ for everything, but is there a compelling reason to buy PyCharm? | Comparison of IntelliJ Python plugin or PyCharm | 0.07983 | 0 | 0 | 23,201 |
3,339,403 | 2010-07-26T22:15:00.000 | 14 | 0 | 1 | 0 | python,excel,vba,csv | 3,339,421 | 13 | false | 0 | 0 | Python is an excellent choice. The csv module makes reading and writing CSV files easy (even Microsoft's, uh, "idiosyncratic" version) and Python syntax is a breeze to pick up.
I'd actually recommend against Perl, if you're coming to it fresh. While Perl is certainly powerful and fast, it's often cryptic to the point of incomprehensible to the uninitiated. | 4 | 17 | 0 | VBA is not cutting it for me anymore. I have lots of huge Excel files to which I need to make lots of calculations and break them down into other Excel/CSV files.
I need a language that I can pick up within the next couple of days to do what I need, because it is kind of an emergency. I have been suggested python, but I would like to check with you if there is anything else that does CSV file handling quickly and easily. | Smallest learning curve language to work with CSV files | 1 | 0 | 0 | 11,359 |
3,339,403 | 2010-07-26T22:15:00.000 | 5 | 0 | 1 | 0 | python,excel,vba,csv | 3,339,414 | 13 | false | 0 | 0 | Python definitely has a small learning curve, and works with csv files well | 4 | 17 | 0 | VBA is not cutting it for me anymore. I have lots of huge Excel files to which I need to make lots of calculations and break them down into other Excel/CSV files.
I need a language that I can pick up within the next couple of days to do what I need, because it is kind of an emergency. I have been suggested python, but I would like to check with you if there is anything else that does CSV file handling quickly and easily. | Smallest learning curve language to work with CSV files | 0.076772 | 0 | 0 | 11,359 |
3,339,403 | 2010-07-26T22:15:00.000 | 2 | 0 | 1 | 0 | python,excel,vba,csv | 3,339,424 | 13 | false | 0 | 0 | That depends on what you want to do with the files.
Python's learning curve is less steep than R's. However, R has a bunch of built-in functions that make it very well suited for manipulating .csv files easily, particularly for statistical purposes.
Edit: I'd recommend R over Python for this purpose alone, if only because the basic operations (reading files, dropping rows, dropping columns, etc.) are slightly faster to write in R than in Python. | 4 | 17 | 0 | VBA is not cutting it for me anymore. I have lots of huge Excel files to which I need to make lots of calculations and break them down into other Excel/CSV files.
I need a language that I can pick up within the next couple of days to do what I need, because it is kind of an emergency. I have been suggested python, but I would like to check with you if there is anything else that does CSV file handling quickly and easily. | Smallest learning curve language to work with CSV files | 0.03076 | 0 | 0 | 11,359 |
3,339,403 | 2010-07-26T22:15:00.000 | 2 | 0 | 1 | 0 | python,excel,vba,csv | 3,339,417 | 13 | false | 0 | 0 | Perl is surprisingly efficient for a scripting language for text. cpan.org has a tremendous number of modules for dealing with CSV data. I've also both written and wrote data in XLS format with another Perl module. If you were able to use VBA, you can certainly learn Perl (the basics of Perl are easy, though it's just as easy for you or others to write terse yet cryptic code). | 4 | 17 | 0 | VBA is not cutting it for me anymore. I have lots of huge Excel files to which I need to make lots of calculations and break them down into other Excel/CSV files.
I need a language that I can pick up within the next couple of days to do what I need, because it is kind of an emergency. I have been suggested python, but I would like to check with you if there is anything else that does CSV file handling quickly and easily. | Smallest learning curve language to work with CSV files | 0.03076 | 0 | 0 | 11,359 |
3,339,971 | 2010-07-27T00:39:00.000 | 0 | 0 | 0 | 1 | java,python,android,sockets | 8,259,497 | 4 | false | 0 | 0 | The Android code is reading lines, so you need probably to send a \n or possibly \r\n at the end of your Python send string. | 1 | 0 | 0 | So I have a simple socket server on an android emulator. When I'm only sending data to it, it works just fine. But then if I want to echo that data back to the python script, it doesn't work at all. Here's the code that works:
android:
try {
serverSocket = new ServerSocket(port);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (checkingForClients) {
try {
clientSocket = serverSocket.accept();
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
clientSocket.getInputStream()));
line = null;
while ((line = in.readLine()) != null) {
Log.d("ServerActivity", line);
/* THIS IS THE LINE THAT DOESN'T WORK*/
//out.println(line);
handler.post(new Runnable() {
@Override
public void run() {
if(incomingData == null){
Log.e("Socket Thingey", "Null Error");
}
//out.println(line);
incomingData.setText("Testing");
incomingData.setText(line);
}
});
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
python:
import socket
host = 'localhost'
port = 5000
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send('Hello, World!')
# data = s.recv(size) THIS LINE CAUSES PROBLEMS
s.close()
print 'Received:' , data
So there are 2 commented lines. Without those lines, it works perfectly. But if I add in s.recv(size) in python it just freezes and I assume waits for the received data. But the problem is that the android code never gets the sent data. So I have no idea what to do.
Keep in mind I'm new to python and to sockets. | python receiving from a socket | 0 | 0 | 1 | 2,058 |
3,340,152 | 2010-07-27T01:28:00.000 | 3 | 0 | 0 | 0 | python,urllib | 3,340,185 | 1 | false | 0 | 0 | You can call getcode() on the object you get back from urlopen().
getcode() gives you the HTTP status response from the server, so you can test to see if you got an HTTP 200 response, which would mean the download was successful. | 1 | 1 | 0 | I want to download an image file from potentially 5 sites.
Meaning that if the image wasn't found in site#1, try site#2, etc.
How can I test if the file was downloaded? | When download an image, does urllib have a return code if it's successful or not? | 0.53705 | 0 | 1 | 153 |
3,340,639 | 2010-07-27T03:55:00.000 | 0 | 0 | 1 | 0 | python,user-interface | 3,340,779 | 2 | false | 0 | 1 | For a cross-platform solution, you could use wxPython with a wxSTAY_ON_TOP style bit in a main window. I believe that this will give you the behavior you desire on Mac and Unix GUIs as well as Microsoft Windows ones. | 1 | 0 | 0 | Just wondering if there is any kind of framework or method of making a Gui that will override (Stay on top of) all other windows in python. Including Games or other programs that seem to "Take over" the computers Graphical processes. Any point in the right direction would be much appreciated...
PS. The OS in question is Windows 7, but a cross platform solution would be appreciated. | GUI's Over Running Programs in python | 0 | 0 | 0 | 99 |
3,340,775 | 2010-07-27T04:39:00.000 | 1 | 0 | 1 | 0 | python,installation | 3,365,859 | 4 | false | 0 | 0 | In Python 3.x, print is now function and needs (). | 2 | 0 | 0 | I downloaded and installed Python 3.1.2 on Windows 7 x64. But it seems that it's not working as expected.
What's wrong here? | What's wrong with my Python installation? | 0.049958 | 0 | 0 | 181 |
3,340,775 | 2010-07-27T04:39:00.000 | 0 | 0 | 1 | 0 | python,installation | 3,340,871 | 4 | false | 0 | 0 | As stated above python 3.x now requires all statements such as those to be function calls, Python 3.x is supposed to bring back the functional aspect of C to python although code that works in 3.x will most likely work in 2.x but not necessarily the other way around. | 2 | 0 | 0 | I downloaded and installed Python 3.1.2 on Windows 7 x64. But it seems that it's not working as expected.
What's wrong here? | What's wrong with my Python installation? | 0 | 0 | 0 | 181 |
3,340,803 | 2010-07-27T04:44:00.000 | 2 | 0 | 1 | 0 | python | 3,340,981 | 3 | false | 0 | 0 | The "asking" part, as @Zonda's answer says, could use raw_input (or Python 3's input) at a terminal ("command window" in Windows); but it could also use a web application, or a GUI application -- you don't really tell us enough about where the users will be (on the same machine you're using to run your code, or at a browser while your code runs on a server?) and whether GUI or textual interfaces are preferred, so it's impossible to give more precise advice.
For storing and retrieving the data, a SQL engine as mentioned in @aaron's answer is a possibility (though some might consider it overkill if this is all you want to save), but his suggested alternative of using pickle directly makes little sense -- I would instead recommend the shelf module, which offers (just about) the equivalent of a dictionary persisted to disk. (Keys, however, can only be strings -- but even if your IDs are integers instead, that's no problem, just use str(someid) as the key both to store and to retrieve).
In a truly weird comment I see you ask...:
is there any way to do it by making a
class? and using the __init__
method?
Of course there is a way to do "in a class, using the __init__ method" most anything you can do in a function -- at worst, you write all the code that would (in a sensible program) be in the function, in the __init__ method instead (in lieu of return, you stash the result in self.result and then get the .result attribute of the weirdly useless instance you have thus created).
But it makes any sense to use a class only when you need special methods, or want to associate state and behavior, and you don't at all explain why either condition should apply here, which is why I call your request "weird" -- you provide absolutely no context to explain why you would at all want that in lieu of functions.
If you can clarify your motivations (ideally by editing your question, or, even better, asking a separate one, but not by extending your question in sundry comments!-) maybe it's possible to help you further. | 1 | 0 | 0 | say i want to ask the many users to give me their ID number and their name, than save it.
and than i can call any ID and get the name. can someone tell me how i can do that by making a class and using the _ _ init _ _ method? | saving data and calling data python | 0.132549 | 0 | 0 | 250 |
3,343,082 | 2010-07-27T11:25:00.000 | 0 | 0 | 0 | 0 | python,soap,xml-rpc,xmlrpclib | 3,343,497 | 2 | false | 0 | 0 | Whether or not possible support of multicall makes any difference to you depends on where the 700ms is going.
How did you measure your 700ms?
Run a packet capture of a query and analyse the results. It should be possible to infer roughly round-trip-time, bandwidth constraints, whether it's the application layer of the server or even the name resolution of your client machine. | 1 | 0 | 0 | Can I ask for few question in one post to XML-RPC server?
If yes, how can I do it in python and xmlrpclib?
I'm using XML-RPC server on slow connection, so I would like to call few functions at once, because each call costs me 700ms. | Does XML-RPC in general allows to call few functions at once? | 0 | 0 | 1 | 231 |
3,343,793 | 2010-07-27T12:54:00.000 | 3 | 0 | 1 | 1 | python,user-interface,windows-services | 3,343,894 | 2 | true | 0 | 0 | If you give your Service the Allow service to interact with desktop permission it will be able to create windows without the need to launch a subprocess. | 1 | 0 | 0 | I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has the same privileges as the service.
So how do I start a process from a Python Windows Service that has the ability to display GUIs on the screen? | Starting a GUI process from a Python Windows Service | 1.2 | 0 | 0 | 1,456 |
3,345,785 | 2010-07-27T16:32:00.000 | 0 | 0 | 1 | 0 | python,iterator | 19,849,720 | 19 | false | 0 | 0 | This is against the very definition of an iterator, which is a pointer to an object, plus information about how to get to the next object.
An iterator does not know how many more times it will be able to iterate until terminating. This could be infinite, so infinity might be your answer. | 5 | 192 | 0 | Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? | Getting number of elements in an iterator in Python | 0 | 0 | 0 | 184,194 |
3,345,785 | 2010-07-27T16:32:00.000 | 0 | 0 | 1 | 0 | python,iterator | 3,346,287 | 19 | false | 0 | 0 | It's common practice to put this type of information in the file header, and for pysam to give you access to this. I don't know the format, but have you checked the API?
As others have said, you can't know the length from the iterator. | 5 | 192 | 0 | Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? | Getting number of elements in an iterator in Python | 0 | 0 | 0 | 184,194 |
3,345,785 | 2010-07-27T16:32:00.000 | 3 | 0 | 1 | 0 | python,iterator | 3,345,950 | 19 | false | 0 | 0 | There are two ways to get the length of "something" on a computer.
The first way is to store a count - this requires anything that touches the file/data to modify it (or a class that only exposes interfaces -- but it boils down to the same thing).
The other way is to iterate over it and count how big it is. | 5 | 192 | 0 | Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? | Getting number of elements in an iterator in Python | 0.031568 | 0 | 0 | 184,194 |
3,345,785 | 2010-07-27T16:32:00.000 | 9 | 0 | 1 | 0 | python,iterator | 3,345,902 | 19 | false | 0 | 0 | An iterator is just an object which has a pointer to the next object to be read by some kind of buffer or stream, it's like a LinkedList where you don't know how many things you have until you iterate through them. Iterators are meant to be efficient because all they do is tell you what is next by references instead of using indexing (but as you saw you lose the ability to see how many entries are next). | 5 | 192 | 0 | Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? | Getting number of elements in an iterator in Python | 1 | 0 | 0 | 184,194 |
3,345,785 | 2010-07-27T16:32:00.000 | 8 | 0 | 1 | 0 | python,iterator | 3,505,917 | 19 | false | 0 | 0 | Regarding your original question, the answer is still that there is no way in general to know the length of an iterator in Python.
Given that you question is motivated by an application of the pysam library, I can give a more specific answer: I'm a contributer to PySAM and the definitive answer is that SAM/BAM files do not provide an exact count of aligned reads. Nor is this information easily available from a BAM index file. The best one can do is to estimate the approximate number of alignments by using the location of the file pointer after reading a number of alignments and extrapolating based on the total size of the file. This is enough to implement a progress bar, but not a method of counting alignments in constant time. | 5 | 192 | 0 | Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting? | Getting number of elements in an iterator in Python | 1 | 0 | 0 | 184,194 |
3,345,916 | 2010-07-27T16:49:00.000 | 10 | 0 | 0 | 0 | java,python,html,django,mobile | 3,346,150 | 8 | false | 1 | 0 | Django wasn't trying to innovate in how web sites are displayed in the browser. Their goal was to simplify the process of building a web site. They could have taken on new ways of creating widgets in the browser as part of that goal, but they didn't. There was plenty of pain to relieve in the classic construction of websites.
If you are building web sites, you will be dealing with HTML. Your analogy to assembler is interesting, but in that analogy, no popular higher-level languages have emerged. This is likely because every higher-level language would of necessity impose some constraints on what could be expressed, and the web is not at the point of wanting conformity like that.
Python is an easier-to-use language than C++, and you really can develop faster in it. You should try it. Automatic memory management is one reason, but others are easy-to-use data structures, not having to ask permission from the compiler to do what you want, extensive third-party libraries to build on, and a clutter-free language in which to express yourself. About the speed: web sites are not compute-bound, they are I/O-bound, so the speed of the language rarely makes a difference.
About the ad-hoc nature of web development. You're coming from a Windows development background, where one vendor defined the entire environment, and did a good job of it. Web development is ad-hoc because the web itself is ad-hoc. No one group defined it, it's grown organically with contributions from many. | 5 | 6 | 0 | I am trying to get a handle on the state of the art regarding web site development and have several questions. Maybe I'll end up finding most of the answers on my own. I come from a background of C++ and Windows development, and generally I am befuddled by what seems to be the ad-hoc nature of web development.
I focussed in on Django, after online research of it and Ruby (on Rails). From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time). So I have gotten into Django - downloaded Python and Django, the source from a complete Django site, got it running, and so forth.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site. When you build a Django view or template, it will still be making extensive reference to html from what I can see (And presumably also Javascript - but I haven't actually even seen any Javascript in Django templates yet.)
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
There is one site in particular that would to me as an end user represent the state of the art for web sites and I would be curious as to what the foundations of such a site might be. That site is chess.com, and there are all sorts of facilities for playing chess online with other users, user customization of their account with various graphical effects and so on. Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets? Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
So anyway, a bunch of newbie questions - will probably end up answering most of them myself if they're not answered here. Maybe they're relevant to someone else though. | Big picture questions regarding Django, Java, Python, HTML and web-site development in general | 1 | 0 | 0 | 1,807 |
3,345,916 | 2010-07-27T16:49:00.000 | 7 | 0 | 0 | 0 | java,python,html,django,mobile | 3,346,994 | 8 | false | 1 | 0 | All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site
Correct. Good assessment. Is that a problem?
html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it
False. Indeed, not even close. All browsers uses HTML. That cannot be changed easily.
chess.com... Is it most likely Java applets they're using for a site like that?
Use view source in your browser to answer this question for yourself. In general, you should do this for every web site you visit. You'll learn a great deal about the web and web development.
Would Django be used in conjunction with something like Flash or even Java applets
Yes. We use FLEX and Django.
Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Yes.
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's?
Yes.
Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
Some people like to despise Java. There's little technical merit to their argument.
After you've used Java and Python, you'll find that Python's less wordy. You get more done with less typing.
what is the justification for their [Python PHP] existence?
They're better than the alternatives. For specific things people need to do, Python (or PHP) are better than the alternatives. For "everything" or even a broad class of things, it may not be perfectly clear.
We do a lot of ad-hoc data crunching. Python's flexibility is absolutely superior to the alternatives.
First of all, Python is much, much slower than say C++, being interpreted.
That's hardly relevant, it turns out. Web sites are not governed by raw speed of one element of the architecture.
Why are websites written in Python or PHP
It's easier than the alternatives.
is platform independence the sole issue here.
No.
I am incredulous that application development is much faster in Python than C++
Have you done much with Python? You should give it a try for a year or so. It makes C++ quite tedious and error-prone by comparison.
is that what the primary reason for Python is - garbage collection.
No. | 5 | 6 | 0 | I am trying to get a handle on the state of the art regarding web site development and have several questions. Maybe I'll end up finding most of the answers on my own. I come from a background of C++ and Windows development, and generally I am befuddled by what seems to be the ad-hoc nature of web development.
I focussed in on Django, after online research of it and Ruby (on Rails). From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time). So I have gotten into Django - downloaded Python and Django, the source from a complete Django site, got it running, and so forth.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site. When you build a Django view or template, it will still be making extensive reference to html from what I can see (And presumably also Javascript - but I haven't actually even seen any Javascript in Django templates yet.)
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
There is one site in particular that would to me as an end user represent the state of the art for web sites and I would be curious as to what the foundations of such a site might be. That site is chess.com, and there are all sorts of facilities for playing chess online with other users, user customization of their account with various graphical effects and so on. Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets? Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
So anyway, a bunch of newbie questions - will probably end up answering most of them myself if they're not answered here. Maybe they're relevant to someone else though. | Big picture questions regarding Django, Java, Python, HTML and web-site development in general | 1 | 0 | 0 | 1,807 |
3,345,916 | 2010-07-27T16:49:00.000 | 1 | 0 | 0 | 0 | java,python,html,django,mobile | 3,452,710 | 8 | false | 1 | 0 | And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
That's why I use Seaside. You still have to understand html and css and javascript, but at least there is a programming language abstraction over html. I'll never go back to a template based system. | 5 | 6 | 0 | I am trying to get a handle on the state of the art regarding web site development and have several questions. Maybe I'll end up finding most of the answers on my own. I come from a background of C++ and Windows development, and generally I am befuddled by what seems to be the ad-hoc nature of web development.
I focussed in on Django, after online research of it and Ruby (on Rails). From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time). So I have gotten into Django - downloaded Python and Django, the source from a complete Django site, got it running, and so forth.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site. When you build a Django view or template, it will still be making extensive reference to html from what I can see (And presumably also Javascript - but I haven't actually even seen any Javascript in Django templates yet.)
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
There is one site in particular that would to me as an end user represent the state of the art for web sites and I would be curious as to what the foundations of such a site might be. That site is chess.com, and there are all sorts of facilities for playing chess online with other users, user customization of their account with various graphical effects and so on. Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets? Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
So anyway, a bunch of newbie questions - will probably end up answering most of them myself if they're not answered here. Maybe they're relevant to someone else though. | Big picture questions regarding Django, Java, Python, HTML and web-site development in general | 0.024995 | 0 | 0 | 1,807 |
3,345,916 | 2010-07-27T16:49:00.000 | 1 | 0 | 0 | 0 | java,python,html,django,mobile | 3,347,792 | 8 | false | 1 | 0 | From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time).
Well, first of all, you shouldn't believe everything you read on the Internet:
I wouldn't say RoR isn't ready for primetime. RoR, like any tool, has its uses. If you're building a site like Twitter, maybe Rails isn't the best tool (as Twitter found out). While everyone thinks they're building a high-performance site, most developers aren't, and Rails will probably be suitable. Furthermore, Rails can scale, and a lot of work has been done to improve that situation even more.
The reason Rails sometimes has performance issues is not because it tries to do everything for you -- it's more because of the nature of the Ruby interpreter itself, which (until Ruby 1.9) was rather slow, and still isn't even as fast as other interpreted languages.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site.
Yes, but that is the innovation. Prior to frameworks like Django and Rails, a lot of that backend work was done by hand. Django frees up a developer's time to work on more application-level features.
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
Yeah, pretty much. Nothing better than HTML, CSS, and JS has presented itself. While I agree that in some ways, HTML seems "low-level" in the same sense that assembly language is low-level, I think most would agree that, relative to problem domain, HTML is much nicer to work with.
Would Django be used in conjunction with something like Flash or even Java applets?
You can. Flash and Java are just embedded in HTML pages, and Django spits out HTML, so that's certainly possible.
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
In addition to applets, you can write a backend in Java (Java Server Pages, for example). I think most web developers who have worked with both would agree than Ruby and Python are much nicer to use than Java. Java web frameworks are kind of a pain, Java lacks a REPL, Java has a separate compilation step... Java is also statically typed; you can argue all day about the merits of dynamic typing vs. static typing, but Rails and Django both take advantage of Ruby's and Python's typing and introspection capabilities to make a lot of code less verbose than that of Java. (Whether that makes Ruby and Python better than Java is subjective.)
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
Performance isn't everything. Almost everyone wants to think their code is performance critical, but that's often not the case. As noted in a few other answers, most web apps are I/O bound anyway -- they're either waiting for database access, or waiting on the network, and both of those types of operations are orders of magnitude slower than CPU-intensive tasks, even with slow(er) interpreted languages. Furthermore, a lot of processing in web apps takes place on strings, and string processing is much nicer in Python or Ruby than it is in, e.g., C or C++. Python and Ruby are also more concise languages, and both offer a REPL which can shorten development time. Plus it's easy to write C extension modules in both Python and Ruby, so if you really, really find a code path that calls out for optimization, you can always drop down into C if you want.
Garbage collection is a plus, though. | 5 | 6 | 0 | I am trying to get a handle on the state of the art regarding web site development and have several questions. Maybe I'll end up finding most of the answers on my own. I come from a background of C++ and Windows development, and generally I am befuddled by what seems to be the ad-hoc nature of web development.
I focussed in on Django, after online research of it and Ruby (on Rails). From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time). So I have gotten into Django - downloaded Python and Django, the source from a complete Django site, got it running, and so forth.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site. When you build a Django view or template, it will still be making extensive reference to html from what I can see (And presumably also Javascript - but I haven't actually even seen any Javascript in Django templates yet.)
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
There is one site in particular that would to me as an end user represent the state of the art for web sites and I would be curious as to what the foundations of such a site might be. That site is chess.com, and there are all sorts of facilities for playing chess online with other users, user customization of their account with various graphical effects and so on. Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets? Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
So anyway, a bunch of newbie questions - will probably end up answering most of them myself if they're not answered here. Maybe they're relevant to someone else though. | Big picture questions regarding Django, Java, Python, HTML and web-site development in general | 0.024995 | 0 | 0 | 1,807 |
3,345,916 | 2010-07-27T16:49:00.000 | 2 | 0 | 0 | 0 | java,python,html,django,mobile | 3,347,103 | 8 | false | 1 | 0 | And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
Yup — if you want a website, someone’s going to have to write some HTML.
HTML is unlike assembler in that you can’t write parsers for new languages in HTML. HTML is just a declarative language for adding meaning to text. As such, the main thing is that everyone in the world agrees how how to render it, and what the tags mean. Something new might replace it eventually, but HTML has proven pretty serviceable and resilient so far. It’s also pretty easy to learn, and free.
Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets?
Django really just concerns itself with the server side of websites. It leaves the client side of things (i.e. whatever runs in the browser) up to you. (Aside from the built-in admin site.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's?
I don’t think it’s common. Java applets are hardly used any more, and some people (cough Steve Jobs cough sorry about the cough there, I said “Steve Jobs”) think Flash will go the same way. | 5 | 6 | 0 | I am trying to get a handle on the state of the art regarding web site development and have several questions. Maybe I'll end up finding most of the answers on my own. I come from a background of C++ and Windows development, and generally I am befuddled by what seems to be the ad-hoc nature of web development.
I focussed in on Django, after online research of it and Ruby (on Rails). From what I read, ROR tries to do everything for you behind the scenes and so therefore is slow and unscalable (and overhyped and not ready for prime time). So I have gotten into Django - downloaded Python and Django, the source from a complete Django site, got it running, and so forth.
And the first thing that surprises me about Django, is that there does not seem to be any innovation to speak of regarding actual presentation. All the innovation would concern database issues, business logic, reusability of code, etc - but not actually anything new regarding innovative visual controls or graphics for a web-site. When you build a Django view or template, it will still be making extensive reference to html from what I can see (And presumably also Javascript - but I haven't actually even seen any Javascript in Django templates yet.)
And I would have thought previously that html might be analagous to assembler, so a conventional application developer from years past might know and occasionally even use a little assembler, but generally would hardly ever use it, whereas from what I can see, html (and also CSS and javascript) still have to be mastered and written continually by every web developer, whether they're using Django or anything else. Is that a true statement?
There is one site in particular that would to me as an end user represent the state of the art for web sites and I would be curious as to what the foundations of such a site might be. That site is chess.com, and there are all sorts of facilities for playing chess online with other users, user customization of their account with various graphical effects and so on. Is it most likely Java applets they're using for a site like that? How relevant would Django be for a such a site. Would Django be used in conjunction with something like Flash or even Java applets? Also when a site like chess.com is ported to a mobile device, what is used to write it - the same development tools as for the desktop or something completely different (Yes, I have a lot of catching up to do.)
Are there in fact complete websites written solely in Java, perhaps using very high level Java API's? Why would someone say (as I read somewhere) that they despised Java so that is why they had gotten into Ruby on Rails and Django.
And regarding Python (and also PHP) what is the justification for their existence? First of all, Python is much, much slower than say C++, being interpreted. Why are websites written in Python or PHP - is platform independence the sole issue here. I am incredulous that application development is much faster in Python than C++ (aside from the garbage collection issue - is that what the primary reason for Python is - garbage collection.)
So anyway, a bunch of newbie questions - will probably end up answering most of them myself if they're not answered here. Maybe they're relevant to someone else though. | Big picture questions regarding Django, Java, Python, HTML and web-site development in general | 0.049958 | 0 | 0 | 1,807 |
3,346,262 | 2010-07-27T17:34:00.000 | 1 | 1 | 1 | 0 | python,metaclass,traits | 4,833,132 | 2 | false | 0 | 0 | Specifically, all of the classes in the "published" API will subclass a particular base class, PythonDirectPublic
Rather than adding another metaclass, you could recursively use the result of PythonDirectPublic.subclasses(). | 1 | 9 | 0 | I have an esoteric question involving Python metaclasses. I am creating a Python package for web-server-side code that will make it easy to access arbitrary Python classes via client-side proxies. My proxy-generating code needs a catalog of all of the Python classes that I want to include in my API. To create this catalog, I am using the __metaclass__ special attribute to put a hook into the class-creation process. Specifically, all of the classes in the "published" API will subclass a particular base class, PythonDirectPublic, which itself has a __metaclass__ that has been set up to record information about the class creation.
So far so good. Where it gets complicated is that I want my PythonDirectPublic itself to inherit from a third-party class (enthought.traits.api.HasTraits). This third-party class also uses a __metaclass__.
So what's the right way of managing two metaclasses? Should my metaclass be a subclass of Enthought's metaclass? Or should I just invoke Enthought's metaclass inside my metaclass's __new__ method to get the type object that I will return? Or is there some other mystical incantation to use in this particular circumstance? | Python: Metaclasses all the way down | 0.099668 | 0 | 0 | 715 |
3,346,430 | 2010-07-27T17:58:00.000 | 10 | 1 | 1 | 0 | python,file,seek | 3,346,499 | 12 | false | 0 | 0 | Can you use unix commands? I think using head -1 and tail -n 1 are probably the most efficient methods. Alternatively, you could use a simple fid.readline() to get the first line and fid.readlines()[-1], but that may take too much memory. | 1 | 77 | 0 | I have a text file which contains a time stamp on each line. My goal is to find the time range. All the times are in order so the first line will be the earliest time and the last line will be the latest time. I only need the very first and very last line. What would be the most efficient way to get these lines in python?
Note: These files are relatively large in length, about 1-2 million lines each and I have to do this for several hundred files. | What is the most efficient way to get first and last line of a text file? | 1 | 0 | 0 | 139,998 |
3,346,482 | 2010-07-27T18:05:00.000 | 2 | 1 | 1 | 0 | python,pythonpath | 3,346,786 | 3 | false | 0 | 0 | If you really must have a split package like this, read up on the module level attribute __path__.
In short, make one of the 'src' directories the main one, and give it an __init__.py that appends the path of other 'src' to the __path__ list. Python will now look in both places when looking up submodules of 'src'.
I really don't recommend this for the long term though. It is kind of brittle and breaks if you move things around. | 1 | 3 | 0 | I'm having problems with my PythonPath on windows XP, and I'm wondering if I'm doing something wrong.
Say that I have a project (created with Pydev) that has an src directory. Under src I have a single package, named common, and in it a single class module, named service.py with a class name Service
Say now that I have another project (also created with Pydev) with an src directory and a common package. In the common package, I have a single script, client.py, that imports service.
So in other words, two separate disk locations, but same package.
I've noticed that even if I set my PYTHONPATH to include both src directories, the import fails unless the files are both in the same directory. I get the dreaded no module found.
Am I misunderstanding how python resolves module names? I'm used to Java and its classpath hell. | PYTHONPATH hell with overlapping package structures | 0.132549 | 0 | 0 | 1,088 |
3,346,970 | 2010-07-27T19:04:00.000 | 2 | 0 | 0 | 0 | java,python,android,sl4a | 3,347,032 | 5 | false | 1 | 0 | More likely will depend what type of applications you will develop.
I would start with Java to become familiar with Android SDK. Anyway first you need to look into some examples, tutorials. Most of them are done in Java, and only a few, probably on the dev site of SL4A for that.
Also there is native development Android NDK, that can be programmed with C++.
But anyway Java rules for general applications. | 1 | 12 | 0 | I just ordered an Android smartphone and want to start playing around with creating my own applications. Now the question is which language to use, the native Java or Python using SL4A (former ASE).
I tend to Python, as I know it much better than Java, but I'm wondering what I would be missing using a "second class" language on Android. On the SL4A website it is also stated to be alpha quality software, which is not exactly encouraging.
I'm also not quite sure what the limitations of the scripting environment are and if they would be problematic. | Starting with Android: Java or Python (SL4A) | 0.07983 | 0 | 0 | 11,760 |
3,347,102 | 2010-07-27T19:20:00.000 | 5 | 0 | 1 | 0 | python,iterator | 3,347,150 | 6 | false | 0 | 0 | Nope sorry iterators are not meant to know length they just know what's next which makes them very efficient at going through Collections. Although they are faster they do no allow for indexing which including knowing the length of a collection. | 1 | 14 | 0 | I am looking through some text file for a certain string with the method.
re.finditer(pattern,text) I would like to know when this returns nothing. meaning that it could find nothing in the passed text.
I know that callable iterators, have next() and __iter__
I would like to know if I could get the size or find out if it returns no string matching my pattern. | python -- callable iterator size? | 0.16514 | 0 | 0 | 15,464 |
3,348,912 | 2010-07-27T23:59:00.000 | 0 | 0 | 0 | 0 | python,django,web-applications | 33,887,695 | 3 | false | 1 | 0 | Try Django Rest Framework with angular.
You can have the Django/Django Rest as backend.
For frontend you can have angular or react.js with nodejs or python simplehttp server or grunt or gulp running.
So front end will communicate to django server to get data. For logging in, you could use auth-token and angular cookies.
This will also decrease the load on backend server, since backend does not have to serve html/templates | 1 | 0 | 0 | I am trying to build a django service to which numerous clients will send data. Each client will represent an authenticated user, who might be connected to the internet or not, so the client will aggregate the data and send them when a connection is available. The data should also be persisted locally so that they are accessed quickly without hitting the server.
The nature of the data is simple. It has to do with game achievements, so each user will have a collection of achievements they have achieved. As a consequence, there are no consistency issues, as each user will be sending their own achievement stats, and no user will edit someone else's data.
I am trying to find the most suitable medium for this. My first thought was POST HTTP requests, which the django server will handle. A python client will login and 'send' data by performing these requests. Can anyone suggest better alternatives, or give me reasons why this setup is suitable or not?
I'd also like to know what you would suggest for a format/way to obtain the data from the client side. I was thinking json or yaml
EDIT 2: This question has been revamped after S.Lott's recommendation. | Sending data to django site | 0 | 0 | 0 | 2,883 |
3,349,156 | 2010-07-28T00:56:00.000 | 0 | 1 | 1 | 0 | php,python,c | 3,599,951 | 6 | true | 0 | 0 | No such tool exists yet. | 1 | 5 | 0 | I am looking for a command-line tool that removes all comments from an input
file and returns the stripped output. It'd be nice it supports popular
programming languages like c, c++, python, php, javascript, html, css, etc. It
has to be syntax-aware as opposed to regexp-based, since the latter will catch
the pattern in source code strings as well. Is there any such tool?
I am fully aware that comments are useful information and often leaving them
as they are is a good idea. It's just that my focus is on different use cases. | General utility to remove/strip all comments from source code in various languages? | 1.2 | 0 | 0 | 3,169 |
3,349,445 | 2010-07-28T02:23:00.000 | 4 | 0 | 0 | 0 | php,python,mysql,variables,share | 3,349,485 | 1 | true | 0 | 0 | Store the shared configuration in a plain text file, preferably in a standard format.
You might consider yaml, ini, or json.
I'm pretty sure both PHP and python can very trivially read and parse all three of those formats. | 1 | 0 | 0 | I have some MySQL database server information that needs to be shared between a Python backend and a PHP frontend.
What is the best way to go about storing the information in a manner wherein it can be read easily by Python and PHP?
I can always brute force it with a bunch of str.replace() calls in Python and hope it works if nobody has a solution, or I can just maintain two separate files, but it would be a bunch easier if I could do this automatically.
I assume it would be easiest to store the variables in PHP format directly and do conversions in Python, and I know there exist Python modules for serializing and unserializing PHP, but I haven't been able to get it all figured out.
Any help is appreciated! | Python - PHP Shared MySQL server connection info? | 1.2 | 1 | 0 | 200 |
3,349,614 | 2010-07-28T03:07:00.000 | 0 | 0 | 0 | 0 | python,concurrency,memcached | 3,349,680 | 2 | false | 1 | 0 | Which is a bigger problem: having redundant data, or getting more than one result back for a query?
If the former is the problem, then you've got a nasty concurrency issue to solve on your hands.
If the latter is the problem, however, why not just give each host that's storing values in memcache a unique identifier, and prepend that to any key? | 1 | 0 | 0 | We are using a cluster of memcached servers for caching purpose, in a Django(Python) production, having tried both cmemcache and python-memcache as the API. The problem is under high concurrency, we started to have duplicate key-value pairs, that is to say we are having multi values for a single key. Is there anyone having had the same similar situation and what is the kill?
Since the memcached servers themselves are not communicating with each to maintain the singularity of the key-value pair, this task is left to the client library, so we are trying to understand further how cmemcache and python-memcache works. | Duplicate key-value pairs returned by memcached | 0 | 0 | 0 | 757 |
3,350,068 | 2010-07-28T05:06:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 3,350,082 | 2 | false | 1 | 0 | Looks like you are not doing a commit on the transaction before querying
start a db transaction
update entityX by setting entityX.flag = True
save entityX
COMMIT TRANSACTION
query for entity where flag == True. BUT, here is the problem. This query does NOT return any results. It should have returned entityX, but it did not.
In a transaction, entities will not be persisted until the transaction is commited | 1 | 2 | 0 | I store groups of entities in the google app engine Data Store with the same ancestor/parent/entityGroup. This is so that the entities can be updated in one atomic datastore transaction.
The problem is as follows:
I start a db transaction
I update entityX by setting entityX.flag = True
I save entityX
I query for entity where flag == True. BUT, here is the problem. This query does NOT return any results. It should have returned entityX, but it did not.
When I remove the transaction, my code works perfectly, so it must be the transaction that is causing this strange behavior.
Should updates to entities in the entity group not be visible elsewhere in the same transaction?
PS: I am using Python. And GAE tells me I can't use nested transactions :( | On the google app engine, why do updates not reflect in a transaction? | 0 | 1 | 0 | 215 |
3,350,282 | 2010-07-28T06:02:00.000 | 1 | 0 | 0 | 1 | python,twisted,stackless | 3,350,509 | 2 | false | 0 | 0 | Multiple NICs, the hardware or the kernel interface is the limit. I can only reach 69,000 packets per second with a Broadcom Corporation NetXtreme BCM5704S Gigabit Ethernet adapter. Try a quad Intel Gigabit Server Adapter with all four NICs on the same subnet. | 2 | 1 | 0 | We're building a test harness to push binary messages out on a UDP multicast.
The prototype is using the Twisted reactor loop to push out messages, which is achieving just about the level of traffic we require - about 120000 messages per second.
We have a 16 cores on our test machine, and obviously I'd like to spread this over those cores to really make the harness fly.
Does anyone have any ideas about how we might architect the application (either using an event loop approach or a CSP style approach) to up this output.
Also most of the time in the prototype is spent writing to UDP - as IO I shouldn't be surprised, but am I missing anything?
Any ideas welcome. | Fastest way to produce UDP packets | 0.099668 | 0 | 0 | 371 |
3,350,282 | 2010-07-28T06:02:00.000 | 1 | 0 | 0 | 1 | python,twisted,stackless | 3,352,556 | 2 | false | 0 | 0 | The obvious answer when the question of exploiting multiple cores in a Python application comes up is to use multiple processes. With Twisted, you can use reactor.spawnProcess to launch a child process. You could also just start 16 instances of your application some other way (like a shell script). This requires that your application can operate sensibly with multiple instances running at once, of course. Exactly how you might divide the work so that each process can take on some of it depends on the nature of the work.
I would expect a single GigE link to be saturated long before you have all 16 cores running full tilt though. Make sure you're focusing on the bottleneck in the system. As Steve-o said, you may want multiple NICs in the machine as well. | 2 | 1 | 0 | We're building a test harness to push binary messages out on a UDP multicast.
The prototype is using the Twisted reactor loop to push out messages, which is achieving just about the level of traffic we require - about 120000 messages per second.
We have a 16 cores on our test machine, and obviously I'd like to spread this over those cores to really make the harness fly.
Does anyone have any ideas about how we might architect the application (either using an event loop approach or a CSP style approach) to up this output.
Also most of the time in the prototype is spent writing to UDP - as IO I shouldn't be surprised, but am I missing anything?
Any ideas welcome. | Fastest way to produce UDP packets | 0.099668 | 0 | 0 | 371 |
3,350,972 | 2010-07-28T08:06:00.000 | 0 | 0 | 0 | 0 | python,model-view-controller,design-patterns,pylons | 3,410,261 | 2 | false | 1 | 0 | Model is for your db-related code. All queries go there, including adding new records/updating existing ones.
Controllers are somewhat ambigous, different projects use different approaches to it. Reddit for example does fair bit of what should be View in controllers.
I, for one, prefer to limit my controllers to request processing and generation of some result object collections, which are then delivered to XHTML/XML/JSON views, depending on the type of request (so each controller should be used for both static page generation and AJAX handling).
I really want to start using Pylons but I think in a few months time I'll come back to my code and think "...what the F was I thinking :/"
Well, thats inevitable, you should try different approaches to find the one which suits you best. | 1 | 0 | 0 | I've been getting more and more interested in using Pylons as my Python web framework and I like the idea of MVC but, coming from a background of never using 'frameworks/design patterns/ what ever it\'s called', I don't really know how to approach it.
From what I've read in the Pylons Book, so far, it seems I do the following:
Create my routes in ./config/routes.py
This is where I map URLs to controllers.
Create a controller for the URL
This is where the main body of the code lies. It does all the work and prepares it for viewing
Create my template
I create a template and assign the data from the controller to it
Models... I have no idea what they're for :/
So my question is, can you recommend any reading materials for someone who clearly has no idea what they're doing?
I really want to start using Pylons but I think in a few months time I'll come back to my code and think "...what the F was I thinking :/"
EDIT: A better, summarized, question came to mind:
What code should be placed in the Controller?
What code should I put in the Model?
The view is just the templating, right?
And, in terms of Pylons, the 'lib' folder will contain code shared among Controllers or misc code that doesn't fit anywhere else - Right? | Getting started with Pylons and MVC - Need some guidance on design | 0 | 0 | 0 | 155 |
3,351,110 | 2010-07-28T08:28:00.000 | 2 | 1 | 1 | 0 | c++,python,visual-studio,eclipse | 3,776,671 | 2 | false | 0 | 0 | If the C++ app runs as a separate process then its pretty easy. You can run the process yourself or attach visual studio to existing running process and put break points.
If C++ code is an embedded DLL/LIB then you can use python as debug/launch process. As soon as python will load the DLL/LIB into your python code visual studio will activate your break points.
Alternatively you can also add windows debugger launcher calls to your code. As soon as your code gets executed, you will see a dialog box asking if you want to attach a debugger. | 1 | 4 | 0 | Does any one know how we can do this?
I have python code in eclipse and whenever it calls c++ functions, i want the break point to go to the visual studio c++ project. | Debug C++ code in visual studio from python code running in eclipse | 0.197375 | 0 | 0 | 1,619 |
3,351,484 | 2010-07-28T09:22:00.000 | 1 | 1 | 1 | 0 | python,file | 3,351,513 | 3 | false | 0 | 0 | This is just impossible.
Any user with administrative rights can remove readonly restrictions of any kind.
Another option might be "Write a python program to kill all users over the worls so that they would not be able to change file attributes or security settings" :-) | 3 | 0 | 0 | Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance. | Creating read only text files with python | 0.066568 | 0 | 0 | 3,100 |
3,351,484 | 2010-07-28T09:22:00.000 | 3 | 1 | 1 | 0 | python,file | 3,351,517 | 3 | true | 0 | 0 | This is not python specific.
If the files are made by a different user that the one viewing it the script can make it read-only. As the file is owned by the python user, the viewing user cannot just change the attributes.
So it's very much an OS question, and not a Python question.
Oh, and there is no way to prevent an administrator changing the file, or for the file to be readable but not copyable. | 3 | 0 | 0 | Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance. | Creating read only text files with python | 1.2 | 0 | 0 | 3,100 |
3,351,484 | 2010-07-28T09:22:00.000 | 0 | 1 | 1 | 0 | python,file | 3,352,472 | 3 | false | 0 | 0 | Take a look at os.chmod() function and execute it with appropriate parameters (filename, stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) for your just created file.
On linux other users then you will not be able to change file or change attributes to writable.
Some root user or someone logged into you account will be able to change it though. | 3 | 0 | 0 | Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?
Please suggest.
Thanks in advance. | Creating read only text files with python | 0 | 0 | 0 | 3,100 |
3,351,963 | 2010-07-28T10:28:00.000 | 1 | 0 | 0 | 0 | python,live,charts | 3,352,172 | 3 | false | 0 | 0 | I havent worked with Matplotlib but I've always found gnuplot to be adequate for all my charting needs.
You have the option of calling gnuplot from python or using gnuplot.py
(gnuplot-py.sourceforge.net) to interface to gnuplot. | 1 | 6 | 1 | I am working on a Python application that involves running regression analysis on live data, and charting both. That is, the application gets fed with live data, and the regression models re-calculates as the data updates. Please note that I want to plot both the input (the data) and output (the regression analysis) in the same one chart.
I have previously done some work with Matplotlib. Is that the best framework for this? It seems to be fairly static, I can't find any good examples similar to mine above. It also seems pretty bloated to me. Performance is key, so if there is any fast python charting framework out there with a small footprint, I'm all ears... | Good framework for live charting in Python? | 0.066568 | 0 | 0 | 5,782 |
3,352,563 | 2010-07-28T11:58:00.000 | 2 | 0 | 0 | 0 | python,html,parsing,beautifulsoup,case-insensitive | 3,352,681 | 2 | false | 1 | 0 | BeautifulSoup standardises the parse tree on input. It converts tags to lower-case. You don't have anything to worry about IMO. | 1 | 4 | 0 | I want to catch some tags with BeautifulSoup: Some <p> tags, the <title> tag, some <meta> tags. But I want to catch them regardless of their case; I know that some sites do meta like this: <META> and I want to be able to catch that.
I noticed that BeautifulSoup is case-sensitive by default. How do I catch these tags in a non-case-sensitive way? | Getting BeautifulSoup to catch tags in a non-case-sensitive way | 0.197375 | 0 | 0 | 3,331 |
3,355,822 | 2010-07-28T17:51:00.000 | 0 | 0 | 0 | 0 | python,authentication,httprequest,token | 3,355,925 | 4 | true | 0 | 0 | class urllib2.HTTPSHandler
A class to handle opening of HTTPS URLs.
21.6.7. HTTPPasswordMgr Objects
These methods are available on HTTPPasswordMgr and HTTPPasswordMgrWithDefaultRealm objects.
HTTPPasswordMgr.add_password(realm, uri, user, passwd)
uri can be either a single URI, or a sequence of URIs. realm, user and passwd must be strings. This causes (user, passwd) to be used as authentication tokens when authentication for realm and a super-URI of any of the given URIs is given.
HTTPPasswordMgr.find_user_password(realm, authuri)
Get user/password for given realm and URI, if any. This method will return (None, None) if there is no matching user/password.
For HTTPPasswordMgrWithDefaultRealm objects, the realm None will be searched if the given realm has no matching user/password. | 1 | 7 | 0 | how and with which python library is it possible to make an httprequest (https) with a user:password or a token?
basically the equivalent to curl -u user:pwd https://www.mysite.com/
thank you | python http request with token | 1.2 | 0 | 1 | 2,459 |
3,355,832 | 2010-07-28T17:52:00.000 | 2 | 1 | 0 | 0 | c#,python,file | 3,355,927 | 6 | false | 0 | 0 | You may consider running IronPython - then you can pass values back and forth across C#/Python | 2 | 4 | 1 | I have a C# application that needs to be run several thousand times. Currently it precomputes a large table of constant values at the start of the run for reference. As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.
The table consists of a sorted 2D array (500-3000+ rows/columns) of simple (int x, double y) tuples. I am looking for recommendations concerning the best/simplest way to store and then import this data. For example, I could store the data in a text file like this "(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)" This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of. Any suggestions would be welcome. | Suggestions for passing large table between Python and C# | 0.066568 | 0 | 0 | 1,046 |
3,355,832 | 2010-07-28T17:52:00.000 | 1 | 1 | 0 | 0 | c#,python,file | 3,356,036 | 6 | false | 0 | 0 | CSV is fine suggestion, but may be clumsy with values being int and double. Generally tab or semicomma are best separators. | 2 | 4 | 1 | I have a C# application that needs to be run several thousand times. Currently it precomputes a large table of constant values at the start of the run for reference. As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.
The table consists of a sorted 2D array (500-3000+ rows/columns) of simple (int x, double y) tuples. I am looking for recommendations concerning the best/simplest way to store and then import this data. For example, I could store the data in a text file like this "(x1,y1)|(x2,y2)|(x3,y3)|...|(xn,yn)" This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of. Any suggestions would be welcome. | Suggestions for passing large table between Python and C# | 0.033321 | 0 | 0 | 1,046 |
3,355,962 | 2010-07-28T18:06:00.000 | 0 | 1 | 0 | 0 | python,compression,tiff,imaging,image-formats | 3,357,139 | 2 | false | 0 | 0 | How about running tiffcp with subprocess to convert to LZW (-c lzw switch), then process normally with pylibtiff? There are Windows builds of tiffcp lying around on the web. Not exactly Python-native solution, but still... | 1 | 2 | 1 | I am trying to load a CCITT T.3 compressed tiff into python, and get the pixel matrix from it. It should just be a logical matrix.
I have tried using pylibtiff and PIL, but when I load it with them, the matrix it returns is empty. I have read in a lot of places that these two tools support loading CCITT but not accessing the pixels.
I am open to converting the image, as long as I can get the logical matrix from it and do it in python code. The crazy thing is is that if I open one of my images in paint, save it without altering it, then try to load it with pylibtiff, it works. Paint re-compresses it to the LZW compression.
So I guess my real question is: Is there a way to either natively load CCITT images to matricies or convert the images to LZW using python??
Thanks,
tylerthemiler | What is the best way to load a CCITT T.3 compressed tiff using python? | 0 | 0 | 0 | 1,297 |
3,356,262 | 2010-07-28T18:42:00.000 | 1 | 0 | 1 | 0 | python | 3,356,307 | 7 | false | 0 | 0 | Yes, it would be bad practice to access sys.argv from f.
I would suggest passing the neccessary arguments into f. But since f won't neccessarily be called from main...maybe use a global variable? I normally try to avoid them, but in your case... >.>
I guess it would help to know a little more info about the way the program is setup. :P | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 0.028564 | 0 | 0 | 494 |
3,356,262 | 2010-07-28T18:42:00.000 | 0 | 0 | 1 | 0 | python | 3,356,911 | 7 | false | 0 | 0 | I would generally advise against it, but BaseHttpServer in python actually uses sys.argv[1] to determine which port to listen on. Convenience maybe. | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 0 | 0 | 0 | 494 |
3,356,262 | 2010-07-28T18:42:00.000 | 0 | 0 | 1 | 0 | python | 3,356,308 | 7 | false | 0 | 0 | You definitely don't want to parse sys.argv in some low-level function. To avoid lots of parameter-passing, you could provide a helper-function called by main() that simply stores the filename into a static variable for later use by f(). | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 0 | 0 | 0 | 494 |
3,356,262 | 2010-07-28T18:42:00.000 | 4 | 0 | 1 | 0 | python | 3,356,276 | 7 | false | 0 | 0 | It is bad form to access sys.argv from anywhere other than your main routine since it couples that code to the command line, making it difficult to use from other Python scripts. | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 0.113791 | 0 | 0 | 494 |
3,356,262 | 2010-07-28T18:42:00.000 | 1 | 0 | 1 | 0 | python | 3,356,311 | 7 | false | 0 | 0 | I would recommend setting the file name once, from sys.argv[1] if it exists, or demand user input if it doesn't. Then store it as part of an object, or a global variable. That will prevent having to pass what is essentially a static string all over the place, once it is set. | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 0.028564 | 0 | 0 | 494 |
3,356,262 | 2010-07-28T18:42:00.000 | 6 | 0 | 1 | 0 | python | 3,356,278 | 7 | true | 0 | 0 | It would be a bad practice to always assume that the arguments that your function needs are available on the command-line - what if this code was invoked in some other manner?
A function should declare input parameters for the data it needs to access.
At the very least, passing the necessary argument into f() rather than accessing sys.argv helps make f() much more re-usable. | 6 | 3 | 0 | I am writing a script and I have a function, call it f(), that needs one of the command line arguments (a filename it needs to open). However, f() is not called directly in the main function.
I was wondering if it was bad coding convention to call sys.argv[1] straight from f()? If I don't I would have to pass it as an argument to all of the functions that eventually call f(). | is it bad convention to call sys.argv from somewhere besides main function in python | 1.2 | 0 | 0 | 494 |
3,356,554 | 2010-07-28T19:16:00.000 | 0 | 0 | 0 | 0 | java,python,ipc,multiprocessing,multiple-processes | 35,616,834 | 6 | false | 1 | 0 | I had a similar situation where I had to communicate between a Java process and a Linux process. I used named pipes.
Try mkfifo() implementation in python. | 1 | 17 | 0 | First, a little explanation of why I'm asking this question in the first place:
I'm writing a python program (with a wxPython gui) that needs to call a Java AWT program from python and extract data from it. I have an in-process working solution on Windows. I also have an in-process solution on OSX so long as I run the Java app headless. Unfortunately there is no reasonable solution that I have found for running both GUIs within the same process on OSX because both AWT and WX both want the first thread and cannot share the wx message loop.
What I would like to do is to launch a Java program in a separate process from my Python program and establish a pipe or queue or something for passing data (specifically byte arrays) back and forth.
I'd greatly appreciate any suggestions, or even a nudge in the right direction as I have very little experience with IPC. | IPC (inter process communication) between python and java | 0 | 0 | 0 | 16,516 |
3,356,964 | 2010-07-28T20:01:00.000 | 101 | 0 | 0 | 0 | python,django,internationalization | 3,359,880 | 6 | false | 1 | 0 | Or you can also get this in your views
request.LANGUAGE_CODE | 2 | 110 | 0 | How can I get the current language in the current thread in a model or in the admin? | How can I get the current language in Django? | 1 | 0 | 0 | 85,439 |
3,356,964 | 2010-07-28T20:01:00.000 | 9 | 0 | 0 | 0 | python,django,internationalization | 19,680,511 | 6 | false | 1 | 0 | Just to add that if you do use django.utils.translation.get_language() then you should bear in mind that if that section of code will be called asynchronously (e.g. as a celery task) then this approach won't work due to it running in a different thread. | 2 | 110 | 0 | How can I get the current language in the current thread in a model or in the admin? | How can I get the current language in Django? | 1 | 0 | 0 | 85,439 |
3,357,472 | 2010-07-28T21:03:00.000 | 1 | 0 | 0 | 1 | python,django,celery | 3,358,271 | 2 | false | 0 | 0 | You should store some 'pause' value outside of celery/task queue. I do this with a mailer using celery. I can pause parts of the system by setting values in either memcache or mysql. The tasks then make sure to query the outside resource before executing the task. If it's meant to be paused it sets it does a task.retry() that causes it to go through the retry delay time and such. | 1 | 7 | 0 | Not talking about the delay method.
I want to be able to get a task, given it's task_id and change it's ETA on the fly, before it is executed.
For now I have to cancel it, and re-schedule one. Troublesome if the scheduled process involve a lot of stuff. | How do I delay a task using Celery? | 0.099668 | 0 | 0 | 4,358 |
3,357,489 | 2010-07-28T21:06:00.000 | 4 | 0 | 0 | 1 | python,django,celery | 3,379,809 | 1 | true | 1 | 0 | You can certainly use "natural ids", but then to be really useful they would have to
be reverseable, which doesn't work if you add that timestamp. Also the ids are unique, so two tasks can't have the same id (the behavior then is undefined)
If you have a task to refresh the timeline of a twitter user, then you know that you
only want one task running for each user id at any time, so you could use a natural id like:
"update-twitter-timeline-%s" % (user_id)
then always be able to get the result for that task, or revoke the task using that id, no need to manually store it somewhere and look it up. | 1 | 4 | 0 | For now I get a task_id from the async_result and have to save it the get it back later.
Would be better if I knew what the task_id what made of so I can calculate it back instead of pulling from the DB. E.G: set a task with task_id=("%s-%s" % (user_id, datetime)). | How do I choose a task_id using celery? | 1.2 | 0 | 0 | 604 |
3,357,608 | 2010-07-28T21:23:00.000 | 0 | 0 | 1 | 0 | ironpython | 46,282,462 | 4 | false | 0 | 0 | This will work :
os.rename("c://your_directory/old_folder_name","c://your_directory/new_folder_name") | 2 | 4 | 0 | for example:
how to rename C:\Program Files\Music_Files to C:\Program Files\MusicFiles | IronPython - how to rename a folder name | 0 | 0 | 0 | 5,069 |
3,357,608 | 2010-07-28T21:23:00.000 | 0 | 0 | 1 | 0 | ironpython | 3,357,656 | 4 | false | 0 | 0 | Why not use the .Net libraries, since IronPython can access them?
System.IO.Directory should have a Move method that you can use. | 2 | 4 | 0 | for example:
how to rename C:\Program Files\Music_Files to C:\Program Files\MusicFiles | IronPython - how to rename a folder name | 0 | 0 | 0 | 5,069 |
3,357,779 | 2010-07-28T21:46:00.000 | 0 | 0 | 0 | 0 | python,django,django-admin | 3,357,805 | 1 | true | 1 | 0 | You are probably not serving javascript files properly. To have this functionality, proper javascript must loaded. | 1 | 0 | 0 | In my localhost Django administrator I am able to fill-in Date and Time fields by clicking on the little "Date" and "Time" helper icons next to my pub_date field. However, the same administrator on my Server does NOT show these icons. The server-side admin also doesn't pop open a pop-up window for the little "+" plus sign for fields in related tables. Is there a server setting or something that I've missed?
BTW, my admin media directory is working correctly otherwise.
Thank you in advance!
L. | Django Admin "Helper" Functionality Not Working on Server | 1.2 | 0 | 0 | 78 |
3,357,984 | 2010-07-28T22:13:00.000 | 3 | 0 | 1 | 0 | python,list,tuples | 3,357,997 | 4 | false | 0 | 0 | Lists are mutable (can be changed), tuples are immutable. Typical use: it sounds rather trite but you use lists when you need to change the values. Tuples are generally a little more efficient because of their immutability (unless you are using them like lists and duplicating them a lot...) | 1 | 7 | 0 | Which is more efficient? What is the typical use of each? | What is the difference between lists and tuples in Python? | 0.148885 | 0 | 0 | 3,089 |
3,358,126 | 2010-07-28T22:42:00.000 | 4 | 1 | 0 | 1 | python,winapi,io | 3,358,136 | 2 | false | 0 | 0 | The most obvious thing seems to be losing cross-platform compatibilty. Python runs on a number of different platforms, none of which has a win32 API except MS Windows. | 2 | 1 | 0 | What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api | win32api vs Python | 0.379949 | 0 | 0 | 390 |
3,358,126 | 2010-07-28T22:42:00.000 | 5 | 1 | 0 | 1 | python,winapi,io | 3,358,143 | 2 | true | 0 | 0 | con
(lack of) portability
harder/more error prone
pro
performance (potentially, it must be measured, as will depend on more than just the api calls) | 2 | 1 | 0 | What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api | win32api vs Python | 1.2 | 0 | 0 | 390 |
3,358,666 | 2010-07-29T00:41:00.000 | 0 | 0 | 0 | 0 | python,oracle,cx-oracle | 3,373,296 | 2 | false | 0 | 0 | In the interest of getting shit done that is good enough, we did the abuse of the CLOB I mentioned in my comment. It took less than 30 minutes to get coded up, runs fast and works. | 1 | 0 | 0 | We need to bulk load many long strings (>4000 Bytes, but <10,000 Bytes) using cx_Oracle. The data type in the table is CLOB. We will need to load >100 million of these strings. Doing this one by one would suck. Doing it in a bulk fashion, ie using cursor.arrayvar() would be ideal. However, CLOB does not support arrays. BLOB, LOB, LONG_STRING LONG_RAW don't either. Any help would be greatly appreciated. | Passing an array of long strings ( >4000 bytes) to an Oracle (11gR2) stored procedure using cx_Oracle | 0 | 1 | 0 | 1,252 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.