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,791,905
2010-09-25T00:27:00.000
0
0
1
1
python
3,791,920
4
false
0
0
That seems to work fine for me in the DOS shell.
1
2
0
I'm using a script that someone else wrote in python. It's executed from the command line with 3 arguments. example: "python script.py 1111 2222 3333" It does it's thing and works perfectly. The results are NOT saved though, and I would really like to pipe the output to a text file. Can I simply use similar dos commands to accomplish this? ie "...333 > output.txt" I don't really want to post the script here if possible since it's not really my work.
Output a python script to text file
0
0
0
33,610
3,792,054
2010-09-25T01:26:00.000
1
0
1
1
python,process,ipc,stdout,stdin
3,792,108
2
false
0
0
In most platforms (i.e., operating systems), an existing process's existing file descriptors are inviolate -- the operating system, striving to guarantee process integrity, will be designed to not allow a separate, unrelated process to alter those file descriptors. Nevertheless, if you do specify a very specific and well-identified platform (ideally including the exact version and release of the operating system in question, since security does tend to get tightened in successive releases compared with preceding ones), it's quite possible that there will be available tricks for your purposes. For example, you may be able to exploit some of the hooks which the operating system intends to be used for "remote debuggers" attaching themselves to existing processes -- if, that is, your very specific OS does offer such hooks (not all do!). But, if you want a cross-platform solution, no way. So, I recommend you edit your question, and in particular replace one of the tags with the name of the "one and only" OS you really need to support (in the Q's edited text, please be as specific as possible about the exact versions and releases you absolutely do need to support -- Python has very little indeed to do with the issue, as you need to operate at specific-OS levels, so there's no real need to similarly pinpoint the Python version).
1
2
0
Standard streams are associated with a program. So, suppose there is a program already running in some way (I don't care how or in what way). The goal is to create pipes to the STDIN of the program from different processes (or programs) that run either locally or remotely and stream data into it asynchronously. Available information is (1) the host address and (2) the pid of the program only. How does one implement both cases in Python in this case? Edit: I should have mentioned this presupposition. The intended operating system is Linux with a (fairly) recent kernel.
How do you stream data into the STDIN of a program from different local/remote processes in Python?
0.099668
0
0
1,779
3,792,465
2010-09-25T04:12:00.000
2
1
0
0
python,matlab,statistics,analysis
3,792,494
5
false
0
0
SciPy, NumPy and Matplotlib.
2
8
1
Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?
Among MATLAB and Python, which one is good for statistical analysis?
0.07983
0
0
1,096
3,792,465
2010-09-25T04:12:00.000
3
1
0
0
python,matlab,statistics,analysis
3,792,582
5
false
0
0
I would pick Python because it can be a powerful as Matlab but is free. Also, you can distribute your applications for free and no licensing chains. Matlab is awesome and expensive (it had a great statistical package) and it will glow smoother than Python in the beginning, but not so in the long run. Now, if you really want the best solution then check out R, the statistical package which is de facto in the community. They even have a Python port for it. R is also free software.
2
8
1
Which one among the two languages is good for statistical analysis? What are the pros and cons, other than accessibility, for each?
Among MATLAB and Python, which one is good for statistical analysis?
0.119427
0
0
1,096
3,793,424
2010-09-25T10:34:00.000
1
0
0
0
python,django,subdomain
3,794,000
1
true
1
0
You may be able to do what you need with apache mod_rewrite. Obviously I didn't read the question clearly enough. As for how to do it in django: you could have some middleware that looks at the server name, and redirects according to that (or even sets a variable). You can't do it with the bare url routing system, as that only has path information, not hostname info.
1
2
0
What are the best practices and solutions for managing dynamic subdomains in different technologies and frameworks? I am searching for something to implement in my Django project but those solutions that I saw, don't work. I also tried to use Apache rewrite mod to send requests from subdomain.domain.com to domain.com/subdomain but couldn't realize how to do it with Django. UPDATE: What I need is to create virtual subdomains for my main domain using usernames from the site. So, if I have a new registered user that is called jack, when I go to jack.domain.com, it would operate make some operations. Like if I just went to domain.com/users/jack. But I don't want to create an actual subdomain for each user.
Managing subdomains
1.2
0
0
347
3,793,526
2010-09-25T11:01:00.000
1
0
0
0
python,events,wxpython,mouseevent
3,806,500
1
true
0
1
In the toolbar button's event, you should be able to get the state of the mouse via wx.GetMouseState. Alternatively, you can make your own toolbar with a panel and some wx.Buttons (or other button widgets).
1
0
0
I have a wx.toolbar with some buttons. One of the buttons makes pan left! I want to click on the button and while I keep it pressed, the pan left is made. For now I only saw that the wx.EVT_TOOL only works when mouse left is up. Is there a way to do what I intend ?
How to change my wx.toolbar event?
1.2
0
0
318
3,793,745
2010-09-25T12:18:00.000
1
0
1
0
python,fork,ads
3,793,988
2
false
0
0
One problem I forsee is that it then means that each platform has different behaviour. The next is that not every filesystem OS X supports also supports resource forks (and the way it stores them in non-hfs filesystems is universally hated by everyone else: ._ ) Having said that, I have often been bitten by a .pyc file being used by apache because the apache process can't read the .py file I have replaced. But I think that this is not the solution: a better deployment process is ;)
1
1
0
I'm wondering if it wouldn't be a better if Python would store the compiled code in a file stream of the original source file. This would work on file systems supporting forks/data-streams, and fall-back if this is not possible. On Windows using ADS (Alternative Data Streams) On OS X using resource forks On Linux using extended file attributes if compiled file is under 32k Doing this will solve the problem of polluting the source tree or having problems like after the removal of a .py the .pyc remained and was loaded and used. What do you think about this, sounds like a good idea or not? What issues to do see.
Would it be a good idea to make python store compile code in file stream instead of pyc files?
0.099668
0
0
104
3,794,762
2010-09-25T17:25:00.000
2
0
1
0
python,ruby,generator,enumerator
3,796,237
3
false
0
0
Generators are stack based, Ruby's Enumerators are often specialised (at the interpreter level) and not stack based.
1
20
1
I've been researching the similarities/differences between Ruby and Python generators (known as Enumerators in Ruby), and so far as i can tell they're pretty much equivalent. However one difference i've noticed is that Python Generators support a close() method whereas Ruby Generators do not. From the Python docs the close() method is said to do the following: Raises a GeneratorExit at the point where the generator function was paused. If the generator function then raises StopIteration (by exiting normally, or due to already being closed) or GeneratorExit (by not catching the exception), close returns to its caller." Is there a good reason why Ruby Enumerators don't support the close() method? Or is it an accidental omission? I also discovered that Ruby Enumerators support a rewind() method yet Python generators do not...is there a reason for this too? Thanks
Ruby generators vs Python generators
0.132549
0
0
4,732
3,794,868
2010-09-25T17:54:00.000
8
0
1
0
python,multithreading,thread-safety,thread-local
3,794,914
1
true
0
0
No -- thread local means that each thread gets its own copy of that variable. Using it is (at least normally) thread-safe, simply because each thread uses its own variable, separate from variables by the same name that's accessible to other threads. OTOH, they're not (normally) useful for communication between threads.
1
5
0
Specifically I'm talking about Python. I'm trying to hack something (just a little) by seeing an object's value without ever passing it in, and I'm wondering if it is thread safe to use thread local to do that. Also, how do you even go about doing such a thing?
Does thread-local mean thread safe?
1.2
0
0
718
3,795,605
2010-09-25T21:20:00.000
4
1
0
0
python,ftp,metadata
3,795,678
2
true
0
0
There is no such attribute. You may be unable to GET such file, but it depends on the server software. Also, file access flags may be set one way while the file is being uploaded and then changed when upload is complete; or incomplete file may have modified name (e.g. original_filename.ext.part) -- it all depends on the server-side software used for upload. If you control the server, make your own metadata, e.g. create an empty flag file alongside the newly uploaded file when upload is finished. In the general case, I'm afraid, the best you can do is monitor file size and consider the file completely uploaded if its size is not changing for a while. Make this interval sufficiently large (on the order of minutes).
1
1
0
Python 2.6 My script needs to monitor some 1G files on the ftp, when ever it's changed/modified, the script will download it to another place. Those file name will remain unchanged, people will delete the original file on ftp first, then upload a newer version. My script will checking the file metadata like file size and date modified to see if any difference. The question is when the script checking metadata, the new file may be still being uploading. How to handle this situation? Is there any file attribute indicates uploading status (like the file is locked)? Thanks.
Python to check if file status is being uploading
1.2
0
0
2,665
3,795,914
2010-09-25T23:07:00.000
0
1
1
0
c#,ironpython,.net-assembly,cil,cls-compliant
3,835,553
2
false
0
1
I'm typing this on my phone so please forgive any silly mistakes. To use the compiled assembly, make sure you compile with clr.CompileModules, NOT pyc.py. Then in your C# call the LoadAssembly method on your Python ScriptEngine object. The module can then be imported by calling the ImportModule method on your ScriptEngine. From there if you can take advantage of the dynamic keyword, do so. Otherwise you'll be stuck with some magic string heavy calls to GetVariable. Also note that you'll have to provide the standard library to your compiled Python Assembly in one form or another.
1
1
0
IronPython.net documentation says the MSIL in the assembly isn't CLS-compliant, but is there a workaround?
Is there a way to use IronPython objects and functions (compiled into an assembly) from C# code?
0
0
0
305
3,798,067
2010-09-26T13:49:00.000
0
0
0
0
python
3,805,092
4
false
0
0
Dcolish's answer is good. I'm not sure the idea of executing code that comes in on a network interface is good in itself, though - you will need to take care to verify that you can trust the sending party, especially if this interface is going to be exposed to the Internet or really any production network.
1
0
0
how do i run a python program that is received by a client from server without writing it into a new python file?
network programming in python
0
0
1
387
3,798,606
2010-09-26T16:04:00.000
1
0
0
0
python,windows,web2py
3,798,630
3
false
1
0
If you mean you need code at the server to know the windows id of the current browser user, web2py isn't going to be able to tell you that. Windows authentication has nothing to do with web protocols.
1
3
0
I'm using web2py for an intranet site and need to get current login windows user id in my controller. Whether any function is available?
How to get windows user id in web2py for an intranet application?
0.066568
0
1
996
3,798,629
2010-09-26T16:09:00.000
1
1
0
0
python,django,unit-testing,tdd,bdd
3,799,733
2
true
1
0
You don't have to contain all possibilities in acceptance tests at all - you will still write unit tests. So I would say that a single tests "user can fill in the form, save it and load it back" is enough to start with. Then you can add more tests if you think that a particular aspect of your system is important enough that it needs an acceptance tests. Don't worry about handling all possibilities here, you will still write tons of unit tests where you will test everything! The easiest way to start is to grow your acceptance test in parallel with the code: so start with testing that the user can input data, implement it until it stops failing, then add to the test the condition that the user has to load this data back etc. It will take a while to implement the initial infrastructure for the acceptance test, before you even start writing production code, but you can't escape from it anyway, and there are various benefits to have tests upfront.
2
7
0
I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message. Question is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. Any examples would be most welcome.
"Zero Iteration" - end to end acceptance test in simple contact-form feature
1.2
0
0
479
3,798,629
2010-09-26T16:09:00.000
0
1
0
0
python,django,unit-testing,tdd,bdd
3,799,623
2
false
1
0
This use-case leads to several test-cases (every tests a dedicated possible path of execution). When writing tests focus on one possible outcome, after a while test-suite grows. The first tests then also give you safety net as regression tests to not break anything which you already implemented successfully. My first tests would be: Happy path 1st part frontend-form + controller layer: User passes correct data, controller take the form and log to console/stdout Happy path 2nd part: Instead of logging to stdout, things get stored to database Happy path 3rd part: Follow-up mail gets sent and received by User Validation error handling (user fills form out incorrectly, e.g. misses mandatory fields, wrong email-pattern) ... Fill out the rest ;) Depends on the more detailed requirements... Remember to implement above as simple as possible. When all tests are in place, refactor ruthlessly to make "internal quality" nice.
2
7
0
I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a veeeery simple application in python+django just to try this approach out. I want User to be able to ask a question via contact-form, the question should be then stored in a db, and a signal after completion should be send to notify mailer which will send follow-up message. Question is - how you'd approach this first end-to-end test in this case? Do you have contain all possibilities in this first test, or maybe I'm misunderstanding this whole technique. Any examples would be most welcome.
"Zero Iteration" - end to end acceptance test in simple contact-form feature
0
0
0
479
3,798,728
2010-09-26T16:31:00.000
0
0
0
0
php,python,ajax,mongodb,real-time
3,799,207
2
false
1
0
It depends heavily on the server running said NoSQL solution, amount of data etc... I have played around with Mongo a bit and it is very easy to setup multiple servers to run simultaneously and you would most likely be able to accomplish high concurrency by starting multiple instances on the same box and having them act like a cluster. Luckily Mongo, at least, handles all the specifics so servers can be killed and introduced without skipping a beat (depending on version). By default I believe the max connections is 1000 so starting 5 servers with said configuration would suffice (if your server can handle it obviously) but realistically you would most likely never be hitting 5000 users at the exact same time. I hope for your hardware's sake you would at least come up with a solution that can check to see if new data is available before a full-on fetch. Either via timestamps or Memcache etc... Overall I would tend to believe NoSQL would be much faster than traditional databases assuming you are fetching data and not running reports etc... and your datastore design is intelligent enough to compensate for the lack of complex joins.
2
2
0
Howdie stackoverflow people! So I've been doing some digging regarding these NoSQL databases, MongoDB, CouchDB etc. Though I am still not sure about real time-ish stuff therefore I thought i'd ask around to see if someone have any practical experience. Let's think about web stuff, let's say we've got a very dynamic super ajaxified webapp that asks for various types of data every 5-20 seconds, our backend is python or php or anything other than java really... in cases such as these obviously a MySQL or similar db would be under heavy pressure (with lots of users), would MongoDB / CouchDB run this without breaking a sweat and without the need to create some super ultra complex cluster/caching etc solution? Yes, that's basically my question, if you think that no.. then yes I know there are several types of solutions for this, nodeJS/websockets/antigravity/worm-hole super tech, but I am just interested in these NoSQL things atm and more specifically if they can handle this type of thing. Let's say we have 5000 users at the same time, every 5, 10 or 20 seconds ajax requests that updates various interfaces. Shoot ;]
MongoDB for realtime ajax stuff?
0
1
0
1,738
3,798,728
2010-09-26T16:31:00.000
2
0
0
0
php,python,ajax,mongodb,real-time
3,801,074
2
true
1
0
Let's say we have 5000 users at the same time, every 5, 10 or 20 seconds ajax requests that updates various interfaces. OK, so to get this right, you're talking about 250 to 1000 writes per second? Yeah, MongoDB can handle that. The real key on performance is going to be whether or not these are queries, updates or inserts. For queries, Mongo can probably handle this load. It's really going to be about data size to memory size ratios. If you have a server with 1GB of RAM and 150GB of data, then you're probably not going to get 250 queries / second (with any DB technology). But with reasonable hardware specs, Mongo can hit this speed on a single 64-bit server. If you have 5,000 active users and you're constantly updating existing records then Mongo will be really fast (on par with updating memcached on a single machine). The reason here is simply that Mongo will likely keep the record in memory. So a user will send updates every 5 seconds and the in-memory object will be updated. If you are constantly inserting new records, then the limitation is really going to be one of throughput. When you're writing lots of new data, you're also forcing the index to expand. So if you're planning to pump in Gigs of new data, then you risk saturating the disk throughput and you'll need to shard. So based on your questions, it looks like you're mostly querying/updating. You'll be writing new records, but not 1000 new records / second. If this is the case, then MongoDB is probably right for you. It will definitely get around a lot of caching concerns.
2
2
0
Howdie stackoverflow people! So I've been doing some digging regarding these NoSQL databases, MongoDB, CouchDB etc. Though I am still not sure about real time-ish stuff therefore I thought i'd ask around to see if someone have any practical experience. Let's think about web stuff, let's say we've got a very dynamic super ajaxified webapp that asks for various types of data every 5-20 seconds, our backend is python or php or anything other than java really... in cases such as these obviously a MySQL or similar db would be under heavy pressure (with lots of users), would MongoDB / CouchDB run this without breaking a sweat and without the need to create some super ultra complex cluster/caching etc solution? Yes, that's basically my question, if you think that no.. then yes I know there are several types of solutions for this, nodeJS/websockets/antigravity/worm-hole super tech, but I am just interested in these NoSQL things atm and more specifically if they can handle this type of thing. Let's say we have 5000 users at the same time, every 5, 10 or 20 seconds ajax requests that updates various interfaces. Shoot ;]
MongoDB for realtime ajax stuff?
1.2
1
0
1,738
3,800,925
2010-09-27T03:27:00.000
1
0
1
0
python,image,image-processing
7,101,902
3
false
0
0
If you should generate text or other vector based images (and then save to .png or .jpg), you could also consider Cairo (PyCairo, in this case). I use it a lot. Otherwise, for pixel-level manipulation, PIL is the obvious choice.
1
3
0
What are some of the better libraries for image generation in Python? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format. Thank you for your attention.
Python 2D image generation
0.066568
0
0
8,712
3,801,379
2010-09-27T05:48:00.000
61
0
0
0
python,django,redis
7,722,260
5
false
1
0
Just because Redis stores things in-memory does not mean that it is meant to be a cache. I have seen people using it as a persistent store for data. That it can be used as a cache is a hint that it is useful as a high-performance storage. If your Redis system goes down though you might loose data that was not been written back onto the disk again. There are some ways to mitigate such dangers, e.g. a hot-standby replica. If your data is 'mission-critical', like if you run a bank or a shop, Redis might not be the best pick for you. But if you write a high-traffic game with persistent live data or some social-interaction stuff and manage the probability of data-loss to be quite acceptable, then Redis might be worth a look. Anyway, the point remains, yes, Redis can be used as a database.
1
107
0
I've heard of redis-cache but how exactly does it work? Is it used as a layer between django and my rdbms, by caching the rdbms queries somehow? Or is it supposed to be used directly as the database? Which I doubt, since that github page doesn't cover any login details, no setup.. just tells you to set some config property.
How can I use redis with Django?
1
1
0
75,541
3,802,544
2010-09-27T09:33:00.000
0
1
0
0
python,e-commerce
11,260,331
1
false
1
0
well, if that is the case, I think the only reason I can think up of is that this Satchmo is not that popular so that nobody is willing to port or design a theme for it. I would suggest randomly grab a theme, port it here accordingly
1
3
0
There are two good open source python e-commerce solutions exist: Satchmo and LFS. But I can't find any theme for them. Does at least one open source theme for them exist? There are thousands themes for Magento, osCommerce, OpenCart, but zero themes for Satchmo. Thanks.
Themes for python e-commerce solutions
0
0
0
299
3,805,802
2010-09-27T16:28:00.000
1
0
0
1
python,google-app-engine
3,805,886
2
false
1
0
Typically when I end up doing something more than a trivial demo I need a reason. Figure out something you want to make and stumble through it, learning as you go until it's working. I'd use the google app engine community as a place to get questions answered, they're pretty good for that. As a first app, I'd just have a goal that you're working towards and start asking the community "how do I do this...?"
1
1
0
I want to develop some web apps using Google app engine. I had deployed a guest book application which was their in "gooleappengine" folder by changing its ID.and also was successful.This is simple one.But not getting how to develop complex web apps. Can anyone please suggest me any good Tutarial or example codes Or any books to refer.
New to google app engine ! what to do next?
0.099668
0
0
120
3,805,828
2010-09-27T16:31:00.000
0
0
0
0
python,emacs
3,807,886
4
false
0
0
I find pdbtrack (part of python-mode.el) invaluable
2
5
0
I 'm just starting to use Python, but I'm a very experienced emacs user. I'd trying to decide between python.el and python-mode.el (or any other equivalent mode people can suggest). Currently I'm leaning strongly towards python-mode.el, mainly because it has a useful "indent-region" method... However, there's a couple of features of C-mode that I seem to lack in both modes which is go to the next/previous function (c-beginning-of-defun) (this differs from py-goto-block-up in that 1) there is no py-goto-block-down, and 2) you can use c-b.... to scroll up through multiple functions, but the py-.. only goes out levels) Also, since C has braces, etc, it's easy to find the beginning/end of a current section. py-goto-block-up gives me the beginning of a block, but there is no equivalent for the end of the block... thanks
emacs python mode preferences
0
0
0
1,493
3,805,828
2010-09-27T16:31:00.000
4
0
0
0
python,emacs
3,806,044
4
false
0
0
There are C-M-a and C-M-e in python-mode. They go to start and end, respectively, of the current def or class. They're mapped to beginning-of-defun and end-of-defun by default. There's also C-c C-u, which is mapped to python-beginning-of-block. My python-mode doesn't map python-end-of-block by default, but it's there too.
2
5
0
I 'm just starting to use Python, but I'm a very experienced emacs user. I'd trying to decide between python.el and python-mode.el (or any other equivalent mode people can suggest). Currently I'm leaning strongly towards python-mode.el, mainly because it has a useful "indent-region" method... However, there's a couple of features of C-mode that I seem to lack in both modes which is go to the next/previous function (c-beginning-of-defun) (this differs from py-goto-block-up in that 1) there is no py-goto-block-down, and 2) you can use c-b.... to scroll up through multiple functions, but the py-.. only goes out levels) Also, since C has braces, etc, it's easy to find the beginning/end of a current section. py-goto-block-up gives me the beginning of a block, but there is no equivalent for the end of the block... thanks
emacs python mode preferences
0.197375
0
0
1,493
3,806,082
2010-09-27T17:08:00.000
0
1
0
0
python,facebook
3,806,101
1
false
1
0
You probably need to update the domain in the facebook settings/api key which allow you access.
1
0
0
I changed my domain from abc.com to xyz.com. After that my facebook authentication is not working. It is throwing a key error KeyError: 'access_token'I am using python as my language.
My facebook authentication is not working?
0
0
1
186
3,806,393
2010-09-27T17:43:00.000
1
1
0
0
python
3,806,787
3
false
0
0
It is very difficult to validate an e-mail address because the syntax is so flexible. The best strategy is to send a test e-mail to the entered address.
1
0
0
Is there any python function that validates E-mail addresses, aware of IDN domains ? For instance, user@example.com should be as correct as user@zääz.de or user@納豆.ac.jp Thanks.
Function to validate an E-mail (IDN aware)
0.066568
0
1
548
3,806,473
2010-09-27T17:57:00.000
16
1
0
0
python,time,week-number
3,806,516
17
false
0
0
If your first week starts on the first day of the month you can use integer division: import datetime day_of_month = datetime.datetime.now().day week_number = (day_of_month - 1) // 7 + 1
1
39
0
Does python offer a way to easily get the current week of the month (1:4) ?
Week number of the month?
1
0
0
60,362
3,808,581
2010-09-27T23:17:00.000
0
1
0
0
python,apache,embedded,beagleboard
3,811,703
4
false
1
0
the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. Your device can be a client of the web site. Your web site has two interfaces. HTML interface to people. A non-HTML interface to the device. As a client of a web site, the device will need an HTTP client-side library to send a request to the web site. This request will include the device's IP address, plus all the usual malarky buried in an HTTP request. (There are a bunch of standard headers that are sent in a request) Once the device has made it's initial request, then your web site can save the device's current status and communicate with it through another protocol if you want to do that. (I'm guessing that "I have all the functional parts written on the server and device side" means you have some other protocol for controlling the device, and this protocol isn't based on HTTP.) It might be simplest in the long run to have the device poll the web site for commands or updates or things. That way the device is a pure web client using only HTTP, and your web site is a pure web server, using only HTTP. Then you don't need your more specialized second protocol. Using only HTTP means you can use SSL to assure a secure communication. If your device uses HTTP to get commands and updates, you'll need to work out a usable representation for data that can easily be encoded into HTTP requests and responses. Choices include XML, JSON and YAML. You can always invent your own data format; however, you'll probably be happier debugging a standardized format like JSON. Building these two interfaces in Django is pretty trivial. You'll simply have some URL's which are for people and some which are for your device. You'll have view functions for people that return HTML pages, and view functions for your device that return JSON or XML messages.
1
5
0
I'm currently working on a project where I'm trying to control an embedded device through an Internet facing website. The idea is is that a user can go to a website and tell this device to preform some kind of action. An action on the website would be translated into a series of CLI commands and then sent to the device. Communication could potentially go both ways in the future, but right now I'm focusing on server-to-device. The web server is a LAMP stack using Python (Django) and the device I'm trying to communicate with is a Beagle Board running eLinux. There would be only one device existing at any time communicating to the server. I have all the functional parts written on the server and device side, but I'm having a bit of trouble figuring out how to write the communication layer. One of my big issues is that the device will be mobile and will be moving locations every few days. So, I can't guarantee a static IP address for the device. My networking programming knowledge is pretty minimal so I don't have that great an idea on where to start. Does anyone have any ideas/resources on how I can start developing this kind of communication? Thanks!
Creating a website to communicate with an embedded device
0
0
0
1,776
3,809,314
2010-09-28T02:40:00.000
3
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
3,809,331
19
false
0
0
You can install multiple versions of Python one machine, and during setup, you can choose to have one of them associate itself with Python file extensions. If you install modules, there will be different setup packages for different versions, or you can choose which version you want to target. Since they generally install themselves into the site-packages directory of the interpreter version, there shouldn't be any conflicts (but I haven't tested this). To choose which version of python, you would have to manually specify the path to the interpreter if it is not the default one. As far as I know, they would share the same PATH and PYTHONPATH variables, which may be a problem. Note: I run Windows XP. I have no idea if any of this changes for other versions, but I don't see any reason that it would.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
0.031568
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
81
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
22,626,734
19
false
0
0
What I did was download both 2.7.6 and 3.3.4. Python 3.3.4 has the option to add the path to it in the environment variable so that was done. So basically I just manually added Python 2.7.6. How to... Start > in the search type in environment select "Edit environment variables to your account"1 Scroll down to Path, select path, click edit. Add C:\Python27; so you should have paths to both versions of Python there, but if you don't this you can easily edit it so that you do..... C:\Python27;C:\Python33; Navigate to the Python27 folder in C:\ and rename a copy of python.exe to python2.exe Navigate to the Python34 folder in C:\ and rename a copy of python.exe to python3.exe Test: open up commmand prompt and type python2 ....BOOM! Python 2.7.6. exit out. Test: open up commmand prompt and type python3 ....BOOM! Python 3.4.3. exit out. Note: (so as not to break pip commands in step 4 and 5, keep copy of python.exe in the same directory as the renamed file)
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
1
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
13
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
48,239,658
19
false
0
0
To install and run any version of Python in the same system follow my guide below. For example say you want to install Python 2.x and Python 3.x on the same Windows system. Install both of their binary releases anywhere you want. When prompted do not register their file extensions and do not add them automatically to the PATH environment variable Running simply the command python the executable that is first met in PATH will be chosen for launch. In other words, add the Python directories manually. The one you add first will be selected when you type python. Consecutive python programs (increasing order that their directories are placed in PATH) will be chosen like so: py -2 for the second python py -3 for the third python etc.. No matter the order of "pythons" you can: run Python 2.x scripts using the command: py -2 (Python 3.x functionality) (ie. the first Python 2.x installation program found in your PATH will be selected) run Python 3.x scripts using the command: or py -3 (ie. the first Python 3.x installation program found in your PATH will be selected) In my example I have Python 2.7.14 installed first and Python 3.5.3. This is how my PATH variable starts with: PATH=C:\Program Files\Microsoft MPI\Bin\;C:\Python27;C:\Program Files\Python_3.6\Scripts\;C:\Program Files\Python_3.6\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Intel\Shared ... Note that Python 2.7 is first and Python 3.5 second. So running python command will launch python 2.7 (if Python 3.5 the same command would launch Python 3.5). Running py -2 launches Python 2.7 (because it happens that the second Python is Python 3.5 which is incompatible with py -2). Running py -3 launches Python 3.5 (because it's Python 3.x) If you had another python later in your path you would launch like so: py -4. This may change if/when Python version 4 is released. Now py -4 or py -5 etc. on my system outputs: Requested Python version (4) not installed or Requested Python version (5) not installed etc. Hopefully this is clear enough.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
1
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
0
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
64,577,951
19
false
0
0
I use a simple solution to switch from a version to another version of python, you can install all version you want. All you have to do is creating some variable environment. In my case, I have installed python 2.7 and python 3.8.1, so I have created this environment variables: PYTHON_HOME_2.7=<path_python_2.7> PYTHON_HOME_3.8.1=<path_python_3.8.1> PYTHON_HOME=%PYTHON_HOME_2.7% then in my PATH environment variable I put only %PYTHON_HOME% and %PYTHON_HOME%\Scripts. In the example above I'm using the version 2.7, when I want to switch to the other version I have only to set the PYTHON_HOME=%PYTHON_HOME_3.8.1%. I use this method to switch quickly from a version to another also for JAVA, MAVEN, GRADLE,ANT, and so on.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
0
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
-1
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
43,160,074
19
false
0
0
I have installed both python 2.7.13 and python 3.6.1 on windows 10pro and I was getting the same "Fatal error" when I tried pip2 or pip3. What I did to correct this was to go to the location of python.exe for python 2 and python 3 files and create a copy of each, I then renamed each copy to python2.exe and python3.exe depending on the python version in the installation folder. I therefore had in each python installation folder both a python.exe file and a python2.exe or python3.exe depending on the python version. This resolved my problem when I typed either pip2 or pip3.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
-0.010526
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
1
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
33,527,329
19
false
0
0
Check your system environment variables after installing Python, python 3's directories should be first in your PATH variable, then python 2. Whichever path variable matches first is the one Windows uses. As always py -2 will launch python2 in this scenario.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
0.010526
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
-1
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
21,692,110
19
false
0
0
Only Works if your running your code in your Python IDE I have both Python 2.7 and Python 3.3 installed on my windows operating system. If I try to launch a file, it will usually open up on the python 2.7 IDE. How I solved this issue, was when I choose to run my code on python 3.3, I open up python 3.3 IDLE(Python GUI), select file, open my file with the IDLE and save it. Then when I run my code, it runs to the IDLE that I currently opened it with. It works vice versa with 2.7.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
-0.010526
0
0
242,246
3,809,314
2010-09-28T02:40:00.000
0
0
1
0
python,windows,compatibility,backwards-compatibility,build-environment
17,660,471
19
false
0
0
Install the one you use most (3.3 in my case) over the top of the other. That'll force IDLE to use the one you want. Alternatively (from the python3.3 README): Installing multiple versions On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python3 which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall". For example, if you want to install Python 2.6, 2.7 and 3.3 with 2.7 being the primary version, you would execute "make install" in your 2.7 build directory and "make altinstall" in the others.
8
234
0
I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I "choose" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.
How to install both Python 2.x and Python 3.x in Windows
0
0
0
242,246
3,809,440
2010-09-28T03:16:00.000
0
0
0
1
python,amqp,celery
4,311,856
1
true
1
0
After reading some docs and trying out a few options, I have found that RabbitMQ suffices for most purposes.
1
0
0
I wanted to get your opinions on the merits of different AMQP implementations to be used with celery. I am looking particularly at message prioritization and job queue sizes. What are your thoughts?
AMQP implementations with Celery
1.2
0
0
289
3,809,981
2010-09-28T05:39:00.000
2
1
1
0
php,python,ruby,programming-languages
3,809,997
8
false
0
0
I personally would prefer Ruby, as it goes wonderfully with the Rails framework and is a blast to learn and to work with. I have only used Python a few times. While I know it is powerful, I have never really fallen in love with it the way I have with Ruby (and specifically the Rails framework)
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0.049958
0
0
3,516
3,809,981
2010-09-28T05:39:00.000
1
1
1
0
php,python,ruby,programming-languages
3,810,088
8
false
0
0
To get a quick feel for each and see which one "tastes" better I would suggest taking each one for a spin on a selection of problems on ProjectEeuler. PE is more about algorithms and math but some of thee simpler problems are a great way to get going with syntax and some core library features such as file IO etc.
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0.024995
0
0
3,516
3,809,981
2010-09-28T05:39:00.000
3
1
1
0
php,python,ruby,programming-languages
3,810,286
8
false
0
0
These two languages are so similar that any strong preference will be mostly subjective. They are both the correct answer.
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0.07486
0
0
3,516
3,809,981
2010-09-28T05:39:00.000
1
1
1
0
php,python,ruby,programming-languages
3,869,927
8
false
0
0
i think you should prefer ruby, while python is assumed easier to learn! python is so friendly great language but you rarely find servers with python support most are expensive one's, ruby on rails is great framework many frameworks for other languages are drives from , great cake php is a sort of such a thing. ruby on rails can be found on many servers. how ever if you have specified applications with special clients you can go to python and it's funny frameworks. by the way, i had a lecture on ruby i had a article claim that ruby is a bit more efficient and more quick.
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0.024995
0
0
3,516
3,809,981
2010-09-28T05:39:00.000
0
1
1
0
php,python,ruby,programming-languages
3,869,982
8
false
0
0
pyfunc pretty much said it, but I'd like to offer two more thoughts: 1) Ruby will probably end up being a tiny bit more familiar as it a) can often optionally use a more C-like syntax, b) is not structured quite as foreignly as Python coming from PHP 2) They can both scale well, but Python will probably give you the most bang for your buck (CPU wise - and if you use Ruby, you're probably pretty well off using Ruby Enterprise and mod_rails, aka phusion passenger). That's all - even considering those points, the difference may well be negligible, as the power of the language is all about how you use it, regardless of its inherent pros and cons.
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0
0
0
3,516
3,809,981
2010-09-28T05:39:00.000
1
1
1
0
php,python,ruby,programming-languages
3,811,039
8
false
0
0
No significant difference on the first four criteria. No significant difference on coding speed either - you're going to be slow in both at the start, then you'll get faster. Ruby may be slightly better at managing libraries (Ruby Gems) but Python probably has slightly broader library coverage. No big deal either way. Coming from PHP, I'd guess that Python might be slightly quicker to learn. That might be a reason for choosing Ruby - you might learn a little more. There are a lot of "mights" and "slightlys" there. That's because the two languages are much more similar to each other than either is to PHP. Neither is particularly hard to learn - I'd suggest spending a little time with both and then going deeper with the one you prefer.
6
2
0
I'm considering learning a new language as an alternative to PHP. I'm considering Python and Ruby. Which one is a better language based on the following four criteria, and any other qualifiers you may have? Which is more stable? Which is more scaleable? Which is more secure? Which is easier to learn? EDIT: Keeping the original question intact, I'd like to add one more pair of questions. Which is quicker to code with? Which is quicker to learn? (Based on personal experience only please - to avoid holywars.) EDIT2: Sorry for not clarifying - mostly web development, some desktop programming would be a nice bonus.
Ruby or Python instead of PHP?
0.024995
0
0
3,516
3,810,869
2010-09-28T08:15:00.000
2
0
1
0
python,error-handling,timeout
3,810,878
3
false
0
0
You can't do it without some sort of multithreading or multiprocessing, even if that's hidden under some layers of abstraction, unless that "process" you're running is specifically designed for asynchronicity and calls-back to a known function once in a while. If you describe what that process actually is, it will be easier to provide real solutions. I don't think that you appreciate the power of Python where it comes to implementations that are succinct while being complete. This may take just a few lines of code to implement, even if using multithreading/multiprocessing.
1
4
0
I've been searching on this but can't seem to find an exact answer (most get into more complicated things like multithreading, etc), I just want to do something like a Try, Except statement where if the process doesn't finish within X number of seconds it will throw an exception. EDIT: The reason for this is that I am using a website testing software (selenium) with a configuration that sometimes causes it to hang. It doesn't throw an error, doesn't timeout or do anything so I have no way of catching it. I am wondering what the best way is to determine that this has occured so I can move on in my application, so I was thinking if I could do something like, "if this hasn't finished by X seconds... move on".
Python, Timeout of Try, Except Statement after X number of seconds?
0.132549
0
1
6,285
3,811,197
2010-09-28T09:04:00.000
1
1
0
1
python,file-permissions
3,811,219
4
false
0
0
Start your program with a user that is allowed to write there. For example login to root first (su) or run the script with sudo myscript.py.
1
6
0
I m using shutil.copy from python to copy a list of files. But when i copy the files to /usr/lib/ location, i m getting permission denied as i need to be an administrator to do that. So How could i copy files with admin permission or how could i get the admin password from the user to copy the files? Ideas would be appreciated
Getting admin password while copy file using shutil.copy?
0.049958
0
0
7,772
3,811,674
2010-09-28T10:08:00.000
0
0
0
0
php,python,django,url,screenshot
21,106,018
6
false
1
0
If you are family with Python, you can use PyQt4. This library supports to get screenshot from a url.
1
7
0
There is the URL of page on the Internet. I need to get a screenshot of this page (no matter in which browser). I need a script (PHP, Python (even Django framework)) that receives the URL (string) and output screenshot-file at the exit (file gif, png, jpg). UPD: I need dynamically create a page where opposite to URL will be placed screenshot of the page with the same URL.
Convert URL to screenshot (script)
0
0
1
31,489
3,812,417
2010-09-28T11:58:00.000
0
0
0
1
windows,scripting,time,tracking,python-idle
49,125,177
3
false
0
0
Do check that CanHandleSessionChange property is True or not ? This will be checked from the designer view -> Property Then use OnSessionChange function
1
1
0
Please help me to find a way to track lock/unlock time on my WinXP machine. I've tried windows scheduler - it only logs logins, not locks. Any alternatives? In Miranda's source code I saw implementation via IdleObject tracker, but this way is too long. May be an AutoIt script? Time tracking program (freeware)?
Trigger an event when system locks/unlocks on Windows XP
0
0
0
3,146
3,812,778
2010-09-28T12:43:00.000
2
0
1
0
java,python,html,human-readable
3,812,833
9
false
1
0
One piece of advice is not to be lazy with names. For example, if you have a Java class which is an implementation of the Transformer interface, and it transforms String to Date, don't hesitate to name the class StringToDateTransformerImpl.
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.044415
0
0
407
3,812,778
2010-09-28T12:43:00.000
1
0
1
0
java,python,html,human-readable
3,813,396
9
false
1
0
Proper indentation when writing HTML can be a lifesaver, especially when you're interacting with any sort of nested elements. Just be consistent with the indentation and be sure to update surrounding lines when you move or delete an indented element. This makes it much easier to update the page, as the level of indentation will give a clue as to where you are in the page without resorting to some sort of Ctrl+F maneuver. It's also worth noting that if you're using CSS in conjunction with HTML, proper naming is critical! It will improve your workflow and the readability of your code. I'm also a big fan of indentation, spacing, and comments when writing "real" (Java, Python, C, etc.) code. I lean towards (x + 1) over (x+1) because I personally think it makes a big difference in readability. I space out casts, increments, etc. and they catch my eye much more easily. Be consistent with your bracket/indentation style, and comment liberally - remember, re-writing a method name is not a comment!
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.022219
0
0
407
3,812,778
2010-09-28T12:43:00.000
2
0
1
0
java,python,html,human-readable
3,812,887
9
false
1
0
Well, you can always use the "ignorant test". Show your code to someone who knows absolutely nothing about programmation. If he can see more or less what a function does, the code is probably readable.
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.044415
0
0
407
3,812,778
2010-09-28T12:43:00.000
3
0
1
0
java,python,html,human-readable
3,812,844
9
false
1
0
Try to read your code out loud (or at least in your head).
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.066568
0
0
407
3,812,778
2010-09-28T12:43:00.000
5
0
1
0
java,python,html,human-readable
3,812,826
9
true
1
0
Use consistent casing and naming. Use tabs (and brackets where available) to provide a visual flow. Use comments that explain what's happening conceptually as well as technically. (e.g., //Do we have a valid user? not //Check that user_ID is not -1) I'm sure some more seasoned developers will have more suggestions, but those are my top 3.
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
1.2
0
0
407
3,812,778
2010-09-28T12:43:00.000
5
0
1
0
java,python,html,human-readable
3,812,816
9
false
1
0
Proper indention and informative comments.
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.110656
0
0
407
3,812,778
2010-09-28T12:43:00.000
5
0
1
0
java,python,html,human-readable
3,812,812
9
false
1
0
Make sure your code is well structured (proper indentation, blank lines to separate sections of code, etc.) and use standard, consistent, and fully named (rather than incomprehensible abbreviated) variable names. Others would suggest using proper comments. I would tend to disagree. If your code is well structured and variables well named, then comments would just clutter things up. The exception to the rule being when you must do something counter-intuitive to work around a bug somewhere else (I've had to resort to this in WCF and Entity Framework code in the past).
7
6
0
More specifically making HTML, Java, and python more readable? Does anyone have suggestions for this programming student?
Are there any basic standards and practices for making human readable code?
0.110656
0
0
407
3,813,451
2010-09-28T13:51:00.000
2
0
0
0
python,sockets,system,distributed
3,813,510
1
false
0
0
You can't. Any intermediate nodes can drop your packets or the reply packets from the remote node.
1
1
0
How can I know if a node that is being accessed using TCP socket is alive or if the connection was interrupted and other errors? Thanks!
Python socket programming
0.379949
0
1
240
3,814,365
2010-09-28T15:28:00.000
1
0
0
0
python,xml.etree
3,814,788
1
true
0
0
register_namespace was only introduced in lxml 2.3 (still beta) I believe you can provide an nsmap parameter (dictionary with prefix-uri mappings) when creating an element, but I don't think you can change it for an existing element. (there is an .nsmap property on the element, but changing that doesn't seem to work. There is also a .prefix property on the element, but that's read-only)
1
3
0
I wish to set the namespace prefix in xml.etree. I found register_namespace(prefix, url) on the Web but this threw "unknown attribute". I have also tried nsmap=NSMAP but this also fails. I'd be grateful for example syntax that shows how to add specified namespace prefixes
how to set namespace prefixes in xml.etree
1.2
0
1
1,128
3,817,481
2010-09-28T22:29:00.000
12
0
1
0
python,command-line,python-3.x,argparse
3,817,517
2
true
0
0
It will be in Python 3.2. It was just added in Python 2.7, which was released just this July; Python 3.2 will be the next 3.x release after that date.
1
6
0
does somebody know, why the argparse module didn't make it in python 3? it's new in python 2.7, but the 2.x branch is running out with 2.7. it makes no sense to me not to support it in the actual python 3 branch.
argparse missing in python 3
1.2
0
0
2,789
3,818,405
2010-09-29T02:47:00.000
7
0
1
0
python,matlab,formatting,keyboard-shortcuts
3,818,446
3
false
0
0
Python is a programming language, not an integrated development environment (IDE), therefore it has no "keyboard shortcuts" or the like. Each given development environment may offer different facilities or the like. You appear to consider GNU Readline (typically used in the simple text-mode interpreter environment that many Python executables bundle) as "part of Python" -- but that's a misconception; readline is a perfectly general library for interactive input in command-line environments, and Python only one of the many programs using it. Another environment usually bundled with Python is IDLE, a GUI one, and of course the editing facilities are completely and drastically different. There are many third-party environments such as "Wing IDE" and each offers a drastically different set of editing features and facilities from all the others. To summarize: your question makes no more sense about Python per se than it would about (say) C, or Java, or any other programming languages. Don't let (usually proprietary) programming languages that come with bundled IDEs confuse you on this subject!
2
2
0
After we write a code in Matlab we can use ctrl+A+ctrl+I and ctrl+A+ctrl+J to format our code (comments, loops alignment etc). Is there something similar or any helpful keyboard shortcuts in Python? Also, just like we can use upward arrow to copy our previous command window history in Matlab, is it possible or some keyboard shortcut to do that in Python? Thanks!
Are there any keyboard shortcuts for formatting in Python?
1
0
0
7,325
3,818,405
2010-09-29T02:47:00.000
1
0
1
0
python,matlab,formatting,keyboard-shortcuts
3,818,483
3
false
0
0
If you use the Python IDLE (comes with Python on Windows, readily available on Linux and Unix flavors), most of the formatting work is done for you. For instance, IDLE automatically indents loops and any other code block after a :. This is far better than writing Python scripts in a standard text editor like gedit, emacs, vim, or Notepad, especially since you can simply press F5 to run the script. As for previous commands, the biggest disadvantage to the Python shell is that you cannot press the up arrow to get the last command. However, if you use the non-GUI shell (in the Windows command prompt or a Unix terminal, the command is python), you can use the shell's command recall to get the last command.
2
2
0
After we write a code in Matlab we can use ctrl+A+ctrl+I and ctrl+A+ctrl+J to format our code (comments, loops alignment etc). Is there something similar or any helpful keyboard shortcuts in Python? Also, just like we can use upward arrow to copy our previous command window history in Matlab, is it possible or some keyboard shortcut to do that in Python? Thanks!
Are there any keyboard shortcuts for formatting in Python?
0.066568
0
0
7,325
3,818,703
2010-09-29T04:22:00.000
0
1
0
0
c++,python,boost,lua,embedding
3,819,333
2
false
0
1
If you are planning to just use windows you could use C++/CLI a managed variant of C++. With C++/CLI you can easily mix managed and unmanaged code. You could call the managed classes from any .net language and the unmanaged (exported) functions from C.
1
2
0
I have used Lua.NET on .NET platform and I could call the .NET class/object from Lua and I could call the Lua from .NET Lua API interface. I did the same with the IronPython. I knew the how the .NET binding works. Now I have a C++ project and I want to use the dynamic capabilities. I want to call C++ object which may not be possible from Lua so I may need to call some C API which makes call to C++. Meantime I want to call the Lua from C++. We have configuration data which is best described in table like format in Lua or List & Dict like in Python. We need to enumerate these data structures defined in Lua/Python in C++. When considering Lua to Python in C++ for two way calling, is Python have upper hand with Boost Python library? I don't have experience in Python/C++ binding. I don't have equal experience of using Python in C++ and calling Python from C++.
Lua or Python binding with C++
0
0
0
3,491
3,818,881
2010-09-29T05:10:00.000
0
0
0
0
python,memory-management,numpy
3,819,063
2
false
0
0
If You have matrices with lots of zeros use scipy.sparse.csc_matrix. It's possible to write everything, for example You can override numarray array class.
1
1
1
In using the numpy.darray, I met a memory overflow problem due to the size of data,for example: Suppose I have a 100000000 * 100000000 * 100000000 float64 array data source, when I want to read data and process it in memory with np. It will raise a Memoray Error because it works out all memory for storing such a big array in memory. Then maybe using a disk file / database as a buffer to store the array is a solution, when I want to use data, it will get the necessary data from the file / database, otherwise, it is just a python object take few memory. Is it possible write such a adapter? Thanks. Rgs, KC
using file/db as the buffer for very big numpy array to yield data prevent overflow?
0
0
0
337
3,821,305
2010-09-29T11:49:00.000
5
0
0
0
javascript,python
3,821,323
1
true
1
0
When you use Python for web development, you use it server-side (like PHP). It's not for client-side programming in the same way that JavaScript is. The vast majority of browsers only support JavaScript for client-side programming. If you want client-side code on a site that's using Python on the server, it still has to use JavaScript on the client. (For completeness, there is (or used to be) a way to use Python on the client side by installing PyWin32, but then your site would only work for people with that software installed and configured. I'd also be very dubious about its security.)
1
1
0
I want to add interactivity like clicks, hover, onpage load() to a webpage, if i use python for generating xhtml, will python give essential flavors like javascript?? I'm bit confused and starter in python for web development, so is there need to include old javascript into python or the python only can handle interactivity, events as javascript?
does python gives interactivity as javascript?
1.2
0
0
128
3,821,636
2010-09-29T12:41:00.000
2
0
0
1
python,google-app-engine
3,823,052
1
true
1
0
I've solved this in the past by keeping the status for the tasks in memcached, and polling (via Ajax) to determine when the tasks are finished. If you go this way, it's best if you can always "manually" determine the status of the tasks without looking in memcached, since there's always the (slim) chance that memcache will go down or will get cleared or something as a task is running.
1
1
0
I need to import some data to show it for user but page execution time exceeds 30 second limit. So I decided to split my big code into several tasks and try Task Queues. I add about 10-20 tasks to queue and app engine executes tasks in parallel while user is waiting for data. How can I determine that my tasks are completed to show user data ASAP? Can I somehow iterate over active tasks?
Python App Engine: Task Queues
1.2
0
0
284
3,822,336
2010-09-29T14:01:00.000
6
0
0
0
python,permissions,chmod
3,822,354
3
false
0
0
Read/write is enough if you want to run it by typing python file.py. If you want to run it directly as if it were a compiled program, e.g. ./file.py, then you need execute permission (and the appropriate hash-bang line at the top).
3
4
0
i wrote a py script to fetch page from web,it just read write permission enough,so my question is when we need execute permission?
when we need chmod +x file.py
1
0
1
6,642
3,822,336
2010-09-29T14:01:00.000
0
0
0
0
python,permissions,chmod
3,822,352
3
false
0
0
If you want to be able to run it directly with $ file.py then you'll need the execute bit set. Otherwise you can run it with $ python file.py.
3
4
0
i wrote a py script to fetch page from web,it just read write permission enough,so my question is when we need execute permission?
when we need chmod +x file.py
0
0
1
6,642
3,822,336
2010-09-29T14:01:00.000
5
0
0
0
python,permissions,chmod
3,822,410
3
true
0
0
It's required to do so if you need to run the script in this way: ./file.py. Keep in mind though, you need to put the path of python at the very top of the script: #!/usr/bin/python. But wait, you need to make sure you have the proper path, to do that execute: which python.
3
4
0
i wrote a py script to fetch page from web,it just read write permission enough,so my question is when we need execute permission?
when we need chmod +x file.py
1.2
0
1
6,642
3,822,857
2010-09-29T14:55:00.000
1
0
0
0
python,django-admin,customization
3,831,573
2
false
1
0
If I were you (and I am), I would stop trying to integrate this functionality with the Django admin site. Speaking from experience, you'll find that what you're trying to do is much easier to implement as regular views. Sure, it isn't be as pretty, but something that works beats something that's pretty but doesn't work, right?
1
0
0
I am trying to create a Django admin filter that will get random groups of users. At this point, I have two problems: Applying a custom filter to the User model, and Displaying a random set of users. On #1, I've tried using User.username.random_filter = True, but it comes back with an AttributeError saying that User has no attribute username. On #2, I know I can get 50 random users with User.objects.order_by('?')[:50], but I have not been able to figure out how to get the result of such a query to show up in the admin listing. As far as I can tell, the listing is generated by the URL's GET request, but I've not had any luck ordering with it. Any suggestions?
Django randomly order users in admin
0.099668
0
0
235
3,823,420
2010-09-29T15:57:00.000
1
0
0
0
python,network-protocols
3,824,612
2
false
0
0
It wasn't obvious from your question but if getting answers back synchronously doesn't matter to you (i.e., you are just asking for work to be performed) you might want to consider just using a job queue. It's generally the easiest way to communicate between hosts. If you don't mind depending on AWS using SQS is super simple. If you can't depend on AWS then you might want to try something like RabbitMQ. Many times problems that we think need to be communicated synchronously are really just queues in disguise.
1
0
0
The situation is that I have a small datacenter, with each server running python instances. It's not your usual distributed worker setup, as each server has a specific role with an appropriate long-running process. I'm looking for good ways to implement the the cross-server communication. REST seems like overkill. XML-RPC seems nice, but I haven't played with it yet. What other libraries should I be looking at to get this done? Requirements: Computation servers crunch numbers in the background. Other servers would like to occasionally ask them for values, based upon their calculation sets. I know this seems pretty well aligned with a REST mentality, but I'm curious about other options.
What are good specs/libraries for closed network communication in python?
0.099668
0
1
196
3,823,429
2010-09-29T15:58:00.000
1
0
0
0
wxpython,window,sizer
3,823,479
1
true
0
1
I would create a subclass of wx.Panel for each "slot", then manage them with a grid or box sizer.
1
0
0
all, I want to draw a rectangular or a container with 20 slots inside. it is like a cd container or archive, with empty slot to insert the cd or book. I choose wxPython. for this 20 horizontal empty slots, i see there is wx.BoxSizer(wx.Horizonal) or other sizers to make the layout. my question is, Is it possible to have "visible border and grey background" (to represent the empty slots) for the spaces generated by the wx.BoxSizer? It seems to me that, it is not possible. The sizer seems only to do layout, instead of generating visible subwindow. If it is not possible, I think I need to create a slot window class for this "border and colorful background" feature, and create 20 slot window objects and add into the sizer. Then, I have to use create another window class to represent the book or CD, and insert this CD window to the slot window. This sounds a bit awkard. I do not know if slot window is necessary or maybe wx.sizer (or other sizer) could achieve the same effect as the slot window.
use wxPython to draw a grided rectangular container or box
1.2
0
0
355
3,823,659
2010-09-29T16:22:00.000
0
0
0
0
python,sqlite,full-text-search,fts3,fts4
12,372,189
4
false
0
0
What Naveen said but => For Windows installations: While running setup.py for for package installations... Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use Visual Studio by setting SET VS90COMNTOOLS=%VS100COMNTOOLS% before calling setup.py.
2
13
0
FTS3/FTS4 doesn't work in python by default (up to 2.7). I get the error: sqlite3.OperationalError: no such module: fts3 or sqlite3.OperationalError: no such module: fts4 How can this be resolved?
How to setup FTS3/FTS4 with python2.7 on Windows
0
1
0
6,571
3,823,659
2010-09-29T16:22:00.000
2
0
0
0
python,sqlite,full-text-search,fts3,fts4
3,826,412
4
false
0
0
never mind. installing pysqlite from source was easy and sufficient. python setup.py build_static install fts3 is enabled by default when installing from source.
2
13
0
FTS3/FTS4 doesn't work in python by default (up to 2.7). I get the error: sqlite3.OperationalError: no such module: fts3 or sqlite3.OperationalError: no such module: fts4 How can this be resolved?
How to setup FTS3/FTS4 with python2.7 on Windows
0.099668
1
0
6,571
3,824,249
2010-09-29T17:26:00.000
0
0
0
1
java,python,scripting
3,824,363
3
false
1
0
Have you considered jython? You can: 1) use it to run python scripts (allowing it to call Java classes) 2) compile python into class files, making them usable by normal Java code without jython being present at runtime I've only used it in the first pattern, but I've seen tonnes of docs on the second.
1
3
0
I developed a command-line utility which needs to be called from a Java GUI application. The team in charge on the Java GUI would like to bind my command-line application to a button in the GUI; the Python application is such that at the time we have no time or interest in rewriting it in Java. I have no experience whatsoever in Java, so I ask you: What is the best way to bind a command-line based Python application to a button in a Java-based GUI application? I am very concerned about exception management (how to tell Java that Python failed). Thanks.
Running Python command-line utility from Java
0
0
0
2,293
3,824,734
2010-09-29T18:31:00.000
0
0
0
0
python,selenium
3,825,411
1
true
0
0
I ended up just doing a check of what browser I was running and then returning the string with the '\n ' replaced with '\n' if the browser was firefox.
1
1
0
When I call selenium.get_text("foo") on a certain element it returns back a different value depending on what browser I am working in due to the way each browser handles newlines. Example: An elements string is "hello[newline]how are you today?[newline]Very well, thank you." When selenium gets this back from IE it gets the string "hello\nhow are you today?\nVery well, thank you." When selenium gets this back from Firefox it gets the string "hello\n how are you today?\n Very well, thank you." (Notice that IE changes [newline] into '\n' and Firefox changes it into '\n ') Is there anyway using selenium/python that I can easily strip out this discrepancy? I thought about using .replace("\n ", "\n"), but that would cause issues if there was an intended space after a newline (for whatever reason). Any ideas?
Selenium and Python: remove \n from returned selenium.get_text()
1.2
0
1
1,614
3,824,923
2010-09-29T18:59:00.000
13
0
0
0
python,apache,logging,mod-wsgi
3,825,257
1
true
1
0
Mostly, we use logging and write to sys.stderr. That seems to write to the Apache error_log.
1
12
0
I have a Django project where I have been logging to a file using the standard library logging module. For a variety of reasons I would like to change it so that it writes to the Apache log files. I've seen quite a bit of discussion of how to do this with mod_python, but not mod_wsgi. How do I do this for a project running under mod_wsgi?
How do I write to the apache log files when using mod_wsgi
1.2
0
0
3,241
3,825,200
2010-09-29T19:38:00.000
2
0
1
0
c#,python,linq
3,825,269
2
false
0
0
Enumerable.Aggregate is your answer. reduce(function, list, seed) ==> list.Aggregate(seed, function). In addition, there are many predefined "aggregates", like Sum, Min, Max, Average, etc. You should use Aggregate only when the aggregator is not built-in.
1
3
0
How to apply a function to every element in a list using Linq in C# like the method reduce() in python?
How to apply a function to every element in a list using Linq in C# like the method reduce() in python?
0.197375
0
0
1,094
3,826,552
2010-09-29T23:10:00.000
2
0
0
0
python,sql,memory,sqlite
25,521,707
4
false
0
0
If you are using Linux, you can try tmpfs which is a memory-based file system. It's very easy to use it: mount tmpfs to a directory. copy sqlite db file to the directory. open it as normal sqlite db file. Remember, anything in tmpfs will be lost after reboot. So, you may copy db file back to disk if it changed.
1
8
0
I have a 100 mega bytes sqlite db file that I would like to load to memory before performing sql queries. Is it possible to do that in python? Thanks
In python, how can I load a sqlite db completely to memory before connecting to it?
0.099668
1
0
12,928
3,826,604
2010-09-29T23:23:00.000
2
1
0
0
python,android,debugging,build,trace
9,443,567
2
false
1
0
I've just experienced an odd effect of using $(info) when compiling a java+C++ Android application: I used $info) to output some informations about conditional compiling in the Android.mk of the main application and when trying to debug the native part of the program, using ndk-gdb, it failed because apparently the output of $(info) is read by the ndk-gdb script (using the get_build_var() and get_build_var_for_abi() functions). THe result is that the ndk-gdb script is not executed properly.
1
3
0
I am building Froyo, is it possible that during building, make/python can output the file and the command it is calling right now. For example, in one of the Android.mk, there is a line, says, echo build success. On the monitor it will show "build success", what I want is that in addition, it shows "Android.mk line 20: echo build success". Is it possible?
Android.mk debug output
0.197375
0
0
4,399
3,829,405
2010-09-30T09:40:00.000
0
0
0
0
python,code-generation,web-crawler,robot
3,829,743
1
true
1
0
You need to separate out the idea of what code to generate from the events triggering generation. What code is generated is governed by the combined set of all the checkboxes that are checked. Triggering code generation occurs each time any of them are changed. You need to regenerate everything at that time. In detail: Check box 1 -- triggers generation, just code for snippet 1 included Check box 2 -- triggers generation, code for snippets 1 & 2 included Check box 3 -- triggers generation, code for snippets 1, 2 & 3 included Uncheck box 2 -- triggers generation, code for snippets 1 & 3 included
1
1
0
I want to write a web-based code generator for a Python crawler. Its aim is to automatically generate code so a developer doesn't need to write it, but I've run into this problem: in one of my project's webpages, there are some checkboxes, buttons, etc. Each of them generates some Python code and writes it to a common textarea. However, when I uncheck boxes I can't figure out how to remove the corresponding code from the textarea, because it's all been mixed together. For example: Check box 1 -- it writes code snippet 1 to the textarea Check box 2 -- it writes code snippet 2 to the textarea Check box 3 -- it writes code snippet 3 to the textarea Uncheck box 2 -- it needs to somehow remove code snippet 2 from the text area, but leave behind code snippets 1 and 3 Is there some way to fix this problem, or any better solution for the whole code generator project?
Problem with web code generator designer
1.2
0
0
82
3,830,294
2010-09-30T11:59:00.000
1
0
0
1
python,sqlite,web-applications,nginx,blob
3,831,317
3
true
1
0
Why so complicated? Serve the image under the name which the user supplied (i.e. http://www.mywebapp.com/images/foo1.jpg) Save the images in a directory using a UUID as name. Create a map of file names to UUIDs in the session. In the handler for /images/ look up the real file name in the map. Return 404 if no such entry exists. Otherwise serve the image. When the session is closed, delete all files from the map. In a cron job, delete all images that are older than one day. This way, several users can upload the same image (same name), images get deleted as soon as possible or by the cron job (if the server crashes or something like that).
2
0
0
I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired. If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out of the session) difficult to stop. Which is why I was considering placing the images in a sqlite db, and serving them from there. It seems that using the db for image storage is considered bad practice (though apparently the GAE blob store seems to provide this functionality), so i was trying to figure out what the alternatives would be. 1) Perhaps I do somesort of url-re-writing like so: http://www.mywebapp.com/images/[session_id]/foo1.jpg Thinking of using nginx, but it seems (on a first look) that this will require some hackin to accomplish? 2) Copy the files to a physical directory on the filesystem and delete when the session expires. this seems quite messy though? Are there any standard methods of accomplishing this dynamic image url thing? I'm using web.py - if that helps. Many thanks!
ensuring dynamic image urls in a web-app: use a blob store?
1.2
0
0
291
3,830,294
2010-09-30T11:59:00.000
-1
0
0
1
python,sqlite,web-applications,nginx,blob
3,830,345
3
false
1
0
A combination of your two ideas (copy to a dir, expire when session expires) could be generalized to creating a new dir (could be as simple as a symlink) every 15 minutes. When generating the new symlink, also remove the one that's an hour old by now. Always link to the newest name in your code.
2
0
0
I want to serve images in a web-app using sessions such that the links to the images expire once the session has expired. If I show the actual links to the filesystem store of the images, say http://www.mywebapp.com/images/foo1.jpg this clearly makes stopping future requests for the image (one the user has signed out of the session) difficult to stop. Which is why I was considering placing the images in a sqlite db, and serving them from there. It seems that using the db for image storage is considered bad practice (though apparently the GAE blob store seems to provide this functionality), so i was trying to figure out what the alternatives would be. 1) Perhaps I do somesort of url-re-writing like so: http://www.mywebapp.com/images/[session_id]/foo1.jpg Thinking of using nginx, but it seems (on a first look) that this will require some hackin to accomplish? 2) Copy the files to a physical directory on the filesystem and delete when the session expires. this seems quite messy though? Are there any standard methods of accomplishing this dynamic image url thing? I'm using web.py - if that helps. Many thanks!
ensuring dynamic image urls in a web-app: use a blob store?
-0.066568
0
0
291
3,830,508
2010-09-30T12:36:00.000
1
1
0
0
python,ssh,ssh-keys
3,830,595
4
false
0
0
paramiko will raise an AuthenticationException if you don't pass a password to the SSHClient's .connect() method and a working key cannot be found.
1
5
0
I would test via a python script whether a passwordless ssh login has been setup or not. If i run the normal ssh command then it will wait to accept the password for some amount of time. Is there a way where the ssh command should return an error as soon as ssh asks for a password. Is it possible to achieve this?
Check if passwordless access has been setup
0.049958
0
0
3,677
3,836,086
2010-10-01T02:10:00.000
1
0
0
0
python,tkinter
3,836,182
2
true
0
1
You want to use wm_geometry and a tiny bit of math to calculate and set a suitable starting position for the second toplevel.
1
1
0
I have a Toplevel widget I'd like it so that it would never appear within the confines of the main Tk window. Basically so that when the Toplevel appears it doesn't cover up any of the main Tk window.
Toplevel widgets in Tkinter
1.2
0
0
348
3,836,620
2010-10-01T04:51:00.000
0
0
0
0
python,continuous
3,836,650
3
false
0
0
If you really wanted to (and wanted to waste a lot of resources), you could cut your loop into 200 ms chunks. So sleep 200 ms, check input, repeat until five minutes elapse, and then check your inbox. I wouldn't recommend it, though. While it's sleeping, though, the process is blocked and won't receive input until the sleep ends. Oh, as an added note, if you hit the key while it's sleeping, it should still go into the buffer, so it'll get pulled out when the sleep ends and input is finally read, IIRC.
1
4
0
I have a script that runs continuously when invoked and every 5 minutes checks my gmail inbox. To get it to run every 5 minutes I am using the time.sleep() function. However I would like user to end the script anytime my pressing q, which it seems cant be done when using time.sleep(). Any suggestions on how i can do this? Ali
Continous loop and exiting in python
0
0
1
5,470
3,836,828
2010-10-01T05:49:00.000
8
1
0
0
python,parsing,cgi,request
39,910,366
2
false
0
0
notice that if you call cgi.FieldStorage() before in your code, you can't get the body data from stdin, because it just be read once.
1
11
0
I just need to write a simple python CGI script to parse the contents of a POST request containing JSON. This is only test code so that I can test a client application until the actual server is ready (written by someone else). I can read the cgi.FieldStorage() and dump the keys() but the request body containing the JSON is nowhere to be found. I can also dump the os.environ() which provides lots of info except that I do not see a variable containing the request body. Any input appreciated. Chris
How to parse the "request body" using python CGI?
1
0
1
8,362
3,839,216
2010-10-01T12:41:00.000
0
0
0
0
javascript,python,html,css,user-interface
3,839,449
10
true
1
0
update: This is an old answer, nowadays you want to go with an embedded browser in your app (*webkit projects etc.), but at the time of writing, no such technology existed. The answer is still valid if you don't want to add quite a few megabytes to your packaged app though. Find a lightweight server, or better - embed one in Your application. That's it. Java has classes for serving http. Python does it well also. See how mercurial's hg serve works. [python] I once did a tiny app that served aspell spellcheck via http on localhost in java with the httprequest class. [worked on win and linux] Create Your application as a server that outputs some html and uses POST to do actions. Do the interface thing in HTML+CSS+JS. Nice and easy. After running point the user to localhost:somesillyport or trigger opening localhost:somesillyport in a browser.
1
11
0
Different languages have different GUI toolkits, but it looks very difficult to achieve attractive user interfaces as good as we can using HTML and CSS with less effort. I don't do my application in javascript as I doubt if it has all the required libraries and I want to do it in python. How do I use rendering engines like gecko, webkit etc in python? Which one will be more suited to work with python?.Is there any 'only html/css' rendering engine without javascript? Will it be easy to write event handlers for DOM events and manipulate DOM in python?
how to write a desktop application which uses HTML and CSS for user interface and python/perl/c++/java for the processing?
1.2
0
0
4,636
3,839,383
2010-10-01T13:02:00.000
1
0
0
1
python,ubuntu-10.04,autostart,wakeup
3,839,956
3
false
0
0
If you want to guarantee it's always running, have a look at man inittab.
2
0
0
I'm trying to setup a Python application that should automatically start when Linux boots. It should also start (unless not already running) if the computer resumes from standby mode - which is mainly the problem. Does anybody know where to integrate these requirements? Thanks, Marius
Creating an autostart application on Ubuntu Linux
0.066568
0
0
1,095
3,839,383
2010-10-01T13:02:00.000
0
0
0
1
python,ubuntu-10.04,autostart,wakeup
3,839,444
3
true
0
0
Configure a cron job every minute to detect if application running - if not start.
2
0
0
I'm trying to setup a Python application that should automatically start when Linux boots. It should also start (unless not already running) if the computer resumes from standby mode - which is mainly the problem. Does anybody know where to integrate these requirements? Thanks, Marius
Creating an autostart application on Ubuntu Linux
1.2
0
0
1,095
3,839,426
2010-10-01T13:07:00.000
2
0
0
0
python,user-interface,qt4,pyqt4
3,839,514
2
true
0
1
You should initializer a pointer to the QWidget (member variable) to 0. When the button is pressed, check if the pointer is 0 - if it is, load and show the widget, and assign the pointer variable to point to the new widget. If the pointer is not null when the button is pressed, call widget->raise() and widget->activateWindow(). Disabled buttons can be frustrating to users, as can buttons which appear to do nothing because e.g. their effect is hidden.
2
2
0
I'm developing a plugin UI for an existing application using PyQt4. The window is created using uic.loadUi() on the press of a button in the main window. The problem is that if I press the button again (while the window is showing) the window is re-created and unsaved changes are lost. I don't want to make the window modal. Which options do I have to cope with this problem? I guess it would be related to checking whether the QWidget is already showing.
How to check if a QWidget is already showing?
1.2
0
0
1,072
3,839,426
2010-10-01T13:07:00.000
0
0
0
0
python,user-interface,qt4,pyqt4
3,839,466
2
false
0
1
I would have thought that this would be handled more by your application logic than anything else. The main window should disable the button after it has been clicked and then re-enable it again when the window is closed. Connect up a closing signal on the secondary window to a slot on the main window to notify the main window when the secondary window is being closed.
2
2
0
I'm developing a plugin UI for an existing application using PyQt4. The window is created using uic.loadUi() on the press of a button in the main window. The problem is that if I press the button again (while the window is showing) the window is re-created and unsaved changes are lost. I don't want to make the window modal. Which options do I have to cope with this problem? I guess it would be related to checking whether the QWidget is already showing.
How to check if a QWidget is already showing?
0
0
0
1,072
3,840,177
2010-10-01T14:37:00.000
2
0
0
0
python,module,importerror
3,840,201
1
true
1
0
You might have more than one python version installed? Check the version you are running. Also, I found using easy_install worked well for installing BeautifulSoup.
1
0
0
I've unpacked BeautifulSoup into c:\python2.6\lib\site-packages, which is in sys.path, but when I enter import BeautifulSoup I get an import error saying no such module exists. Obviously I'm doing something stupid... what is it?
Trouble importing BeautifulSoup in python
1.2
0
0
1,900
3,840,779
2010-10-01T15:44:00.000
0
0
1
0
emacs,python-mode
3,841,767
2
false
0
0
Also running python-mode.el and when I tab a comment it cycles through the indentation levels. What version of emacs are you using? edit getting the behavior you describe if there is a non-space immediately following the #. I always put a space after, but it sounds like a bug to me. I'd ask on the python-mode.el list.
1
1
0
I'm using python-mode.el, and when I try to indent comments, it always wants to put them all the way to the left. I want them indented in line with the rest of the code. Is there an easy way to achieve this?
Tabbing comments in emacs py-mode?
0
0
0
136
3,842,155
2010-10-01T18:47:00.000
0
0
0
0
python,text,tkinter
58,942,250
13
false
0
1
You could use a Label instead. A Label can be edited programmatically and cannot be edited by the user.
1
83
0
It doesn't look like it has that attribute, but it'd be really useful to me.
Is there a way to make the Tkinter text widget read only?
0
0
0
131,968
3,842,558
2010-10-01T19:50:00.000
-1
0
1
0
python,multithreading,pyqt
3,886,587
3
false
0
1
I use pyqtSignal and Python's threading. You can create threads and when the thread is completed have it send a signal to update your GUI.
1
1
0
I am developing an application that uses multiple threads to gather data from a variety of network devices. I'm using PyQT to display the collected data on a GUI. I am using regular python threads (from thread, threading) in my app (instead of QThread). In order to update the GUI on the different threads, I use a lock (thread.allocate_lock()). So, anytime a GUI update will happen, I call with lock, update GUI. Any concerns about this?
PyQT and threads
-0.066568
0
0
7,384
3,842,882
2010-10-01T20:36:00.000
1
0
0
0
python,macos,itunes,sourceforge-appscript,py-appscript
3,843,204
1
true
0
0
Some very few applications are recordable: that is, they'll send Apple Events to themselves which can be intercepted. iTunes is not one of these applications. iTunes does send distributed notifications for music start/stop, but not for rating changes. Assuming you don't want to patch iTunes itself, your only real choice is to parse iTunes Music Library.xml.
1
1
0
Is it possible to subscribe to events using py-appscript ? Example: I'd like to get a callback when a user changes a rating on iTunes.
py-appscript & events
1.2
0
0
282
3,843,218
2010-10-01T21:41:00.000
1
0
0
0
python,drupal
3,843,449
1
true
1
0
If you write API calls and utilize Drupal Services module, you can hook into just about anything and send/receive JSON/XML data.
1
1
0
This week, I want to start a web mapping and data visualization site for my work. Unfortunately, I just found out my work place will be using Drupal in a few months down the road. (Most of my web development experience is with App Engine.) My problem is that I need to make sure my web application embeds nicely into the larger Drupal site that outside consultants plan to make. I am most comfy with Python, and I was expecting to use the Python-Django combo instead. There are important python libraries and modules I must have that cant be found or re-written in PHP. I was thinking I will avoid all django on the web pages so things dont get confusing when the Drupal switch is made. I will have the javascript on the web page make calls to python on the server which then spits out JSON data, and I think this will stay the same even after the Drupal switch. Does this make sense? Any general or specific suggestions that may guide me are greatly appreciated!
Starting a web app now which will use python that later this need to embed nicely into a Drupal site?
1.2
0
0
114
3,844,158
2010-10-02T02:49:00.000
8
1
1
0
python,oop
3,844,175
2
true
0
0
What are these kinda classes classified under OOdesign? Can I do it in a more elegant way? You do have better alternatives, IMHO. I use a class that has just named constants , this class is used directly other classes to get values of constants in it.I dont instantiate the class. For e.g. in this case you don't necessarily need a class. You can have a settings module that defines the various "constants". I put constants in quotes because there are no constants in Python the way there are in say, Java. (2) I use a class with full of static methods, this class is basically used by other classes as a holder of methods that are used by them. So again i dont instantiate the class. Again, no need for a class. You can have one or more modules that contain these methods or rather, functions. They can be logically grouped as you see fit. I'd like to add a note that you don't have to stick to (Java style?) "classes only" approach (for lack of a better phrase). Rather try to write code that doesn't go against the grain of the language. In Python's case I'd argue that such classes as you described above are best avoided. They seem to me like a carry over from Java.
1
2
0
I just want to know how I can call certian classes in design pattern here, like which type are they classified in OO design (1) I use a class that has just named constants , this class is used directly other classes to get values of constants in it.I dont instantiate the class. (2) I use a class with full of static methods, this class is basically used by other classes as a holder of methods that are used by them. So again i dont instantiate the class. What are these kinda classes classified under OOdesign? Can I do it in a more elegant way?
Static or constant or what are they?
1.2
0
0
705
3,844,801
2010-10-02T07:31:00.000
6
0
1
0
python,algorithm,comparison
41,332,976
29
false
0
0
Check if all elements equal to the first. np.allclose(array, array[0])
1
505
0
I need a function which takes in a list and outputs True if all elements in the input list evaluate as equal to each other using the standard equality operator and False otherwise. I feel it would be best to iterate through the list comparing adjacent elements and then AND all the resulting Boolean values. But I'm not sure what's the most Pythonic way to do that.
Check if all elements in a list are identical
1
0
0
489,466
3,845,018
2010-10-02T08:52:00.000
25
0
1
0
python,bitwise-operators,boolean-operations
3,845,096
9
false
0
0
In theory, and and or come straight from boolean logic (and therefore operate on two booleans to produce a boolean), while & and | apply the boolean and/or to the individual bits of integers. There are a lot lot of questions here on how the latter work exactly. Here are practical differences that potentially affect your results: and and or short-circuiting, e.g. True or sys.exit(1) will not exit, because for a certain value of the first operand (True or ..., False and ...), the second one wouldn't change the result so does not need to be evaluated. But | and & don't short-circuit - True | sys.exit(1) throws you outta the REPL. & and | are regular operators and can be overloaded, while and and or are forged into the language (although the special method for coercion to boolean may have side effects). This also applies to some other languages with operator overloading and and or return the value of an operand instead of True or False. This doesn't change the meaning of boolean expressions in conditions - 1 or True is 1, but 1 is true, too. But it was once used to emulate a conditional operator (cond ? true_val : false_val in C syntax, true_val if cond else false_val in Python). For & and |, the result type depends on how the operands overload the respective special methods (True & False is False, 99 & 7 is 3, for sets it's unions/intersection...). This also applies to some other languages like Ruby, Perl and Javascript But even when e.g. a_boolean & another_boolean would work identically, the right solution is using and - simply because and and or are associated with boolean expression and condition while & and | stand for bit twiddling.
1
91
0
I am confused as to when I should use Boolean vs bitwise operators and vs & or vs | Could someone enlighten me as to when do i use each and when will using one over the other affect my results?
Boolean operators vs Bitwise operators
1
0
0
53,143
3,846,875
2010-10-02T17:50:00.000
2
0
1
1
python,twisted
3,846,924
4
false
0
0
Look at the samples that come with twisted's documentation. Also, the documentation is not bad, but it is not very complete. Also, the API docs are quite good in fact. When you know with which part you start, just try and play with the code until you're stuck, then google samples relating to your code and ask on stackoverflow.
2
19
0
How do I begin learning Twisted? What books, documentation or tutorial do you guys recommend? The reason I asked this question is that I think learning Twisted would help me otherwise also in learning concepts related to network programming (terminologies and how it works and stuff) I have heard that the documentation for Twisted is not that good. Is is true? Note that I am looking for some advise that actually helped you. I am looking for your experience. PS: I am aware of the official documentation. There is also the O'Reilly Book on Twisted; is that good?
Learning Twisted
0.099668
0
0
5,772
3,846,875
2010-10-02T17:50:00.000
3
0
1
1
python,twisted
3,846,959
4
false
0
0
The way i learned twisted was by starting a small project and lots of googling around; the twisted tutorials are sometimes not very clear, its just getting used to the framework and the way it works... EDIT: itd also recommend trying to understand what twisted is based on, the whole idea of twisted is to provide event driven programming for python, along with some other features such as asynchronous sockets and web server classes. A quick explanation of deferreds and callbacks, which is the whole idea behind twisted, is creating an event (deferred object), then attaching a callback to it; then at some point ur going to fire the event, and the callback is triggered with a result (it could be null) from ur event operation. A good example is, if you have a button on a form, you create an event (a deferred object) then u attach a callback, when the user clicks a button, they fire the event, and the callback function is called to handle that event. i hope this will give u a good general idea of what twisted is and how it can be used in a python environment, there is also IronPython (.NET) which has eventing as well. ~george
2
19
0
How do I begin learning Twisted? What books, documentation or tutorial do you guys recommend? The reason I asked this question is that I think learning Twisted would help me otherwise also in learning concepts related to network programming (terminologies and how it works and stuff) I have heard that the documentation for Twisted is not that good. Is is true? Note that I am looking for some advise that actually helped you. I am looking for your experience. PS: I am aware of the official documentation. There is also the O'Reilly Book on Twisted; is that good?
Learning Twisted
0.148885
0
0
5,772
3,847,202
2010-10-02T19:29:00.000
0
0
0
1
python,django,google-app-engine
13,424,917
4
false
1
0
If you plan to use Django on app engine, then chances are you will want to use Djangos ORM. Which means.. you will probably be looking at Django non-rel. However there are a few things to consider: Django non-rel runs a few versions behind the latest django release, so some modern features (such as advanced timezone support) are not supported, as of the moment, you will just have to wait. Django non-rel does not support some features such as Django's transactions API and none of the native app engine transaction modules work ether. so all in all, fine for a small simple projects, but when things get more complicated, django non-rel falls short.
2
13
0
I've been learning Python and now I'd like to learn a Python-based web framework. I'm considering Google App Engine and Django. Which one should I choose? What are their unique features and learning curves?
Google App Engine or Django?
0
0
0
5,657