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,358,759 | 2010-07-29T01:04:00.000 | 1 | 0 | 1 | 0 | python,installation,error-handling,pyqt,packages | 3,358,864 | 1 | true | 0 | 1 | The distutils model handles installing a python app correctly, or there is a third party setuptools package that is even easier for end users. | 1 | 0 | 0 | What's a good way to handle fatal errors - missing packages, .ui files not compiled, Qt DLLs or shared objects not found, etc. - in a PyQt app (or other Python app)?
Displaying a cross-platform message box without Qt DLLs or shared objects seems like a lot of work. Dumping a message to the console seems not very helpful, since the end user will likely not see the console. How do other Python apps handle this? Or do they simply assume that a properly installed app won't run into these problems? | Handling missing packages or DLLs in a PyQt app | 1.2 | 0 | 0 | 67 |
3,359,214 | 2010-07-29T03:04:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 3,359,618 | 4 | false | 1 | 0 | An index wouldn't help as them main problem I believe is not so much getting the sorted list as having a DB write with every page view of an article. Another index actually makes that problem worse, albeit only a little.
So I'd go with the cache. I think django's cache shim is a problem here because it requires timeouts on all keys. I'm not sure if that's imposed by memcached, if not then go with redis. Actually just go with redis anyway, the python library is great, I've used it from django projects before, and it has atomic increments and powerful sorting - everything you need. | 3 | 2 | 0 | I'm creating a Django-powered site for my newspaper-ish site. The least obvious and common-sense task that I have come across in getting the site together is how best to generate a "top articles" list for the sidebar of the page.
The first thing that came to mind was some sort of database column that is updated (based on what?) with every view. That seems (to my instincts) ridiculously database intensive and impractical and thus I think I'd like to find another solution.
Thanks all. | Dynamically Created Top Articles List in Django? | 0 | 0 | 0 | 117 |
3,359,214 | 2010-07-29T03:04:00.000 | 0 | 0 | 0 | 0 | python,mysql,django | 3,359,569 | 4 | false | 1 | 0 | If you do something like sort by top views, it would be fast if you index the view column in the DB. Another option is to only collect the top x articles every hour or so, and toss that value into Django's cache framework.
The nice thing about caching the list is that the algorithm you use to determine top articles can be as complex as you like without hitting the DB hard with every page view. Django's cache framework can use memory, db, or file system. I prefer DB, but many others prefer memory. I believe it uses pickle, so you can also store Python objects directly. It's easy to use, recommended. | 3 | 2 | 0 | I'm creating a Django-powered site for my newspaper-ish site. The least obvious and common-sense task that I have come across in getting the site together is how best to generate a "top articles" list for the sidebar of the page.
The first thing that came to mind was some sort of database column that is updated (based on what?) with every view. That seems (to my instincts) ridiculously database intensive and impractical and thus I think I'd like to find another solution.
Thanks all. | Dynamically Created Top Articles List in Django? | 0 | 0 | 0 | 117 |
3,359,214 | 2010-07-29T03:04:00.000 | 1 | 0 | 0 | 0 | python,mysql,django | 3,361,120 | 4 | false | 1 | 0 | Premature optimization, first try the db way and then see if it really is too database sensitive. Any decent database has so good caches it probably won't matter very much. And even if it is a problem, take a look at the other db/cache suggestions here.
It is most likely by the way is that you will have many more intensive db queries with each view than a simple view update. | 3 | 2 | 0 | I'm creating a Django-powered site for my newspaper-ish site. The least obvious and common-sense task that I have come across in getting the site together is how best to generate a "top articles" list for the sidebar of the page.
The first thing that came to mind was some sort of database column that is updated (based on what?) with every view. That seems (to my instincts) ridiculously database intensive and impractical and thus I think I'd like to find another solution.
Thanks all. | Dynamically Created Top Articles List in Django? | 0.049958 | 0 | 0 | 117 |
3,362,859 | 2010-07-29T13:18:00.000 | 6 | 0 | 0 | 0 | javascript,python,screen-scraping | 3,364,608 | 6 | false | 1 | 0 | I would actually suggest using Selenium. Its mainly designed for testing Web-Applications from a "user perspective however it is basically a "FireFox" driver. I've actually used it for this purpose ... although I was scraping an dynamic AJAX webpage. As long as the Javascript form has a recognizable "Anchor Text" that Selenium can "click" everything should sort itself out.
Hope that helps | 1 | 17 | 0 | I'm trying to scrape and submit information to websites that heavily rely on Javascript to do most of its actions. The website won't even work when i disable Javascript in my browser.
I've searched for some solutions on Google and SO and there was someone who suggested i should reverse engineer the Javascript, but i have no idea how to do that.
So far i've been using Mechanize and it works on websites that don't require Javascript.
Is there any way to access websites that use Javascript by using urllib2 or something similar?
I'm also willing to learn Javascript, if that's what it takes. | Scraping websites with Javascript enabled? | 1 | 0 | 1 | 23,351 |
3,363,167 | 2010-07-29T13:47:00.000 | 3 | 1 | 0 | 0 | python,error-handling,bottle | 3,393,377 | 2 | false | 1 | 0 | in the error500 function written after the @error decorator to serve my customized error page, wrote error.exception and error.traceback, these two give the exception and complete traceback of the error message. | 1 | 2 | 0 | I am using the Bottle framework. I have set the @error decorator so I am able to display my customized error page, and i can also send email if any 500 error occurs, but I need the complete traceback to be sent in the email. Does anyone know how to have the framework include that in the e-mail? | E-mail traceback on errors in Bottle framework | 0.291313 | 0 | 0 | 894 |
3,363,831 | 2010-07-29T14:55:00.000 | 1 | 0 | 0 | 1 | python,process | 3,363,869 | 4 | false | 0 | 0 | The daemon could have an open (network) socket, where it accepts commands.
It could monitor changes in a file.
Any other kind of signalling is possible, but these would probably be the most common. | 1 | 5 | 0 | I have a python program that is running as a daemon on Linux.
How to send this daemon a signal from another python program? | communication between python programs | 0.049958 | 0 | 0 | 4,184 |
3,366,499 | 2010-07-29T20:05:00.000 | 2 | 0 | 1 | 0 | python,notepad++,indentation | 30,389,815 | 6 | false | 0 | 0 | Tiny update - to get spaces as tabs, you now go to Settings>>Preferences>>Tab Settings and check the "Replace by space" box | 4 | 50 | 0 | I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening? | Notepad++ indentation messes up | 0.066568 | 0 | 0 | 64,168 |
3,366,499 | 2010-07-29T20:05:00.000 | 106 | 0 | 1 | 0 | python,notepad++,indentation | 3,366,550 | 6 | true | 0 | 0 | There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well)
Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space' | 4 | 50 | 0 | I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening? | Notepad++ indentation messes up | 1.2 | 0 | 0 | 64,168 |
3,366,499 | 2010-07-29T20:05:00.000 | 42 | 0 | 1 | 0 | python,notepad++,indentation | 3,366,526 | 6 | false | 0 | 0 | I would suggest going to View > Show Symbol > Show Whitespace and Tab to get an better idea of how your indentations look. | 4 | 50 | 0 | I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening? | Notepad++ indentation messes up | 1 | 0 | 0 | 64,168 |
3,366,499 | 2010-07-29T20:05:00.000 | 2 | 0 | 1 | 0 | python,notepad++,indentation | 32,338,760 | 6 | false | 0 | 0 | I am new to python and started using Notepad++. But I faced the same issue as you... Indentation problems. On my senior's advice, I switched to PyCharm community edition. I pasted the code from Notepad++ to PyCharm and it highlighted the block with indentation problems... The issue was that, some of the lines used spaces and some used tabs. This happened because the code on which I was working was taken from the internet.
Checking for such inconsistencies would solve the problem. Or, there is a better alternative... Switch to PyCharm. It is exclusively built for python coding.. Hope this helps people like me searching for solutions for indentation issues in Notepad++ | 4 | 50 | 0 | I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening? | Notepad++ indentation messes up | 0.066568 | 0 | 0 | 64,168 |
3,367,808 | 2010-07-29T23:41:00.000 | 5 | 0 | 1 | 0 | python,mobile | 3,367,841 | 2 | false | 0 | 0 | No. Python is an excellent language, but there is nothing about it makes it especially preferred for mobile development. | 2 | 1 | 0 | a lot of my friends are using Python to build their mobile applications and games.
is python the preferred language for mobile applications for developers? if so, why? | is python the preferred language for mobile applications? | 0.462117 | 0 | 0 | 3,114 |
3,367,808 | 2010-07-29T23:41:00.000 | 3 | 0 | 1 | 0 | python,mobile | 3,367,854 | 2 | true | 0 | 0 | No, there is no preferred language for mobile development. Each mobile platform has its own supported language or set of supported languages. Android is programmed primarily with Java (although development in C++ and Python are also supported), while the iPhone is programmed with Objective-C. A common theme in mobile is to implement the core functionality of the application as a webservice, and then to implement a UI for a specific mobile platform that is a thin client to the web service. While the UI will be written in whichever language(s) are supported by the platform, the language that you use for the webservice can be whatever programming language(s) you choose to run on your webserver. If you use a cloud computing service, then that would be whatever languages are supported by that service (e.g. if you use Google AppEngine, then Python and Java are both supported languages). | 2 | 1 | 0 | a lot of my friends are using Python to build their mobile applications and games.
is python the preferred language for mobile applications for developers? if so, why? | is python the preferred language for mobile applications? | 1.2 | 0 | 0 | 3,114 |
3,367,986 | 2010-07-30T00:37:00.000 | 0 | 0 | 0 | 0 | python,wxpython,hide | 22,358,518 | 3 | false | 0 | 1 | statictext.Show to show
and
statictext.Hide to hide | 3 | 4 | 0 | I was wondering how to hide/delete a StaticText in wxPython? | Hide/Delete a StaticText in wxPython | 0 | 0 | 0 | 3,670 |
3,367,986 | 2010-07-30T00:37:00.000 | 5 | 0 | 0 | 0 | python,wxpython,hide | 3,368,074 | 3 | true | 0 | 1 | Have you tried control.Hide() or control.Show(False)? | 3 | 4 | 0 | I was wondering how to hide/delete a StaticText in wxPython? | Hide/Delete a StaticText in wxPython | 1.2 | 0 | 0 | 3,670 |
3,367,986 | 2010-07-30T00:37:00.000 | 5 | 0 | 0 | 0 | python,wxpython,hide | 3,371,640 | 3 | false | 0 | 1 | The widget's Hide/Show methods should work. If the widget is in a sizer, then you can use the sizer's Detach method to "hide" it but not destroy it. Otherwise, the sizer has a Remove method that will remove the widget and destroy it. And there's the widget's own Destroy method. | 3 | 4 | 0 | I was wondering how to hide/delete a StaticText in wxPython? | Hide/Delete a StaticText in wxPython | 0.321513 | 0 | 0 | 3,670 |
3,368,459 | 2010-07-30T03:02:00.000 | 0 | 0 | 1 | 1 | python | 3,368,490 | 3 | false | 0 | 0 | If it's not in site-packages then you can add a file with the extension .pth to your site-packages directory.
The file should have one path per line, that you want included in sys.path | 1 | 1 | 0 | I have been programming in Python for a while now, and have created some utilities that I use a lot. Whenever I start a new project, I start writing, and as I need these utilities I copy them from where ever I think the latest version of the particular utility is. I have enough projects now that I am losing track of where the latest version is. And, I will upgrade one of these scripts to fix a problem in a specific situation, and then wish it had propagated back to all of the other projects that use that script.
I am thinking the best way to solve this problem is to create a directory in the site-packages directory, and put all of my utility modules in there. And then add this directory to the sys.path directory list.
Is this the best way to solve this problem?
How do modify my installation of Python so that this directory is always added to sys.path, and I don't have to explicitly modify sys.path at the beginning of each module that needs to use these utilities?
I'm using Python 2.5 on Windows XP, and Wing IDE. | How do I setup python to always include my directory of utility files | 0 | 0 | 0 | 147 |
3,368,740 | 2010-07-30T04:43:00.000 | 6 | 0 | 0 | 0 | python,image-processing,python-imaging-library | 3,368,847 | 2 | true | 0 | 0 | You would be much better off using the EXTENT rather than the AFFINE method. You only need to calculate two things: what part of the input you want to see, and how large it should be. For example, if you want to see the whole image scaled down to half size (i.e. zooming out by 2), you'd pass the data (0, 0, im.size[0], im.size[1]) and the size (im.size[0]/2, im.size[1]/2). | 1 | 7 | 1 | I'm writing a simple application in Python which displays images.I need to implement Zoom In and Zoom Out by scaling the image.
I think the Image.transform method will be able to do this, but I'm not sure how to use it, since it's asking for an affine matrix or something like that :P
Here's the quote from the docs:
im.transform(size, AFFINE, data, filter) => image
Applies an affine transform to the image, and places the result in a new image with the given size.
Data is a 6-tuple (a, b, c, d, e, f) which contain the first two rows from an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel.
This function can be used to scale, translate, rotate, and shear the original image. | Zooming With Python Image Library | 1.2 | 0 | 0 | 7,941 |
3,369,073 | 2010-07-30T06:16:00.000 | 0 | 0 | 0 | 0 | python,browser,webbrowser-control | 3,370,550 | 6 | false | 0 | 0 | Depends what do you actually want to achieve. If you need to do some automatic stuff w/out user interference, you can just use underlying engine of the browser, like Gecko or WebKit, w/out loading browser itself. There are ready Python bindings to these engines available.
Browsers themself do not provide this kind of API to outside processes. For Firefox, you would need to inject some browser-side code into chrome, either as extension or plugin. | 2 | 27 | 0 | Is it possible to control a web browser like Firefox using Python?
I would want to do things like
launch the browser
force clicks on URLs
take screenshots
etc. | Controlling Browser using Python? | 0 | 0 | 1 | 50,784 |
3,369,073 | 2010-07-30T06:16:00.000 | 1 | 0 | 0 | 0 | python,browser,webbrowser-control | 3,370,579 | 6 | false | 0 | 0 | Ag great way to control a browser in Python is to use PyQt4.QtWebKit. | 2 | 27 | 0 | Is it possible to control a web browser like Firefox using Python?
I would want to do things like
launch the browser
force clicks on URLs
take screenshots
etc. | Controlling Browser using Python? | 0.033321 | 0 | 1 | 50,784 |
3,369,080 | 2010-07-30T06:17:00.000 | 1 | 1 | 0 | 1 | python,centos | 3,369,157 | 3 | false | 0 | 0 | you can use cgi, but that will not have great performance as it starts a new process for each request.
More efficient alternatives are to use fastcgi or wsgi
A third option is to run a mini Python webserver and proxy the requests from apache using rewrite rules | 1 | 0 | 0 | I'm a LAMP developer trying out Python for the first time.. I'm okay with picking up the syntax, but I can't figure out how to run it on the server! I've tried the following
uploading filename.py to a regular web/public directory. chmod 777, 711, 733, 773... (variations of execute)
putting the filename.py in cgi-bin, chmod same as above..
Typing up example.com/filename.py simply loads a textfile - nothing appears to have been compiled/parsed/etc!
(I believe python is installed, as
whereis python on my server shows /usr/bin/python among several other directories)
Many words for a simple question - how do you run a python file on a CentOS server? | Running a .py file on LAMP (CentOS) server - from a PHP developer's perspective | 0.066568 | 0 | 0 | 5,711 |
3,369,640 | 2010-07-30T08:02:00.000 | 0 | 0 | 1 | 0 | python,oop | 3,369,782 | 4 | false | 0 | 0 | Its usually used when class is used as function with some instance context, like some DecoratorClass which would be used as @DecoratorClass('some param'), so 'some param' would be stored in the instance's namespace and then instance being called as actual decorator.
It is not very useful when your class provides some different methods, since its usually not obvious what would the call do, and explicit is better than implicit in these cases. | 4 | 32 | 0 | What are peoples' opinions on using the __call__. I've only very rarely seen it used, but I think it's a very handy tool to use when you know that a class is going to be used for some default behaviour. | When is using __call__ a good idea? | 0 | 0 | 0 | 4,325 |
3,369,640 | 2010-07-30T08:02:00.000 | 33 | 0 | 1 | 0 | python,oop | 3,369,912 | 4 | true | 0 | 0 | I think your intuition is about right.
Historically, callable objects (or what I've sometimes heard called "functors") have been used in the OO world to simulate closures. In C++ they're frequently indispensable.
However, __call__ has quite a bit of competition in the Python world:
A regular named method, whose behavior can sometimes be a lot more easily deduced from the name. Can convert to a bound method, which can be called like a function.
A closure, obtained by returning a function that's defined in a nested block.
A lambda, which is a limited but quick way of making a closure.
Generators and coroutines, whose bodies hold accumulated state much like a functor can.
I'd say the time to use __call__ is when you're not better served by one of the options above. Check the following criteria, perhaps:
Your object has state.
There is a clear "primary" behavior for your class that's kind of silly to name. E.g. if you find yourself writing run() or doStuff() or go() or the ever-popular and ever-redundant doRun(), you may have a candidate.
Your object has state that exceeds what would be expected of a generator function.
Your object wraps, emulates, or abstracts the concept of a function.
Your object has other auxilliary methods that conceptually belong with your primary behavior.
One example I like is UI command objects. Designed so that their primary task is to execute the comnand, but with extra methods to control their display as a menu item, for example, this seems to me to be the sort of thing you'd still want a callable object for. | 4 | 32 | 0 | What are peoples' opinions on using the __call__. I've only very rarely seen it used, but I think it's a very handy tool to use when you know that a class is going to be used for some default behaviour. | When is using __call__ a good idea? | 1.2 | 0 | 0 | 4,325 |
3,369,640 | 2010-07-30T08:02:00.000 | 0 | 0 | 1 | 0 | python,oop | 3,369,712 | 4 | false | 0 | 0 | More generally, Python has a lot of double-underscore methods. They're there for a reason: they are the Python way of overloading operators. For instance, if you want a new class in which addition, I don't know, prints "foo", you define the __add__ and __radd__ methods. There's nothing inherently good or bad about this, any more than there's anything good or bad about using for loops.
In fact, using __call__ is often the more Pythonic approach, because it encourages clarity of code. You could replace MyCalculator.calculateValues( foo ) with MyCalculator( foo ), say. | 4 | 32 | 0 | What are peoples' opinions on using the __call__. I've only very rarely seen it used, but I think it's a very handy tool to use when you know that a class is going to be used for some default behaviour. | When is using __call__ a good idea? | 0 | 0 | 0 | 4,325 |
3,369,640 | 2010-07-30T08:02:00.000 | 3 | 0 | 1 | 0 | python,oop | 3,369,658 | 4 | false | 0 | 0 | Use it if you need your objects to be callable, that's what it's there for
I'm not sure what you mean by default behaviour
One place I have found it particularly useful is when using a wrapper or somesuch where the object is called deep inside some framework/library. | 4 | 32 | 0 | What are peoples' opinions on using the __call__. I've only very rarely seen it used, but I think it's a very handy tool to use when you know that a class is going to be used for some default behaviour. | When is using __call__ a good idea? | 0.148885 | 0 | 0 | 4,325 |
3,371,008 | 2010-07-30T11:28:00.000 | 1 | 0 | 1 | 0 | python,window | 3,371,085 | 1 | true | 0 | 0 | Ohh, I found the solution by repairing the Python 2.6 installation. | 1 | 0 | 0 | What information about Python 2.6 stored in the Windows registry, under HKEY_LOCAL_MACHINE/SOFTWARE? Where is it stored?
Somehow I lost it in my regedit and can't install a module. I googled it, but I can't find any answer, and I don't have an extra computer to try and many modules that I need for my school project is installed inside, so I don't want to take the risk to uninstall. | How to store Python 2.6 value in regedit | 1.2 | 0 | 0 | 182 |
3,371,136 | 2010-07-30T11:50:00.000 | 15 | 0 | 1 | 0 | python,virtualenv | 58,513,801 | 6 | false | 0 | 0 | Go to your venv folder and open pyvenv.cfg. (E.g. if your virtual environment is called myenv then the file will be located at myenv\pyvenv.cfg)
You'll see a boolean setting called include-system-site-packages
Set that setting to true to use global packages
If you want to disable using global packages, just set that setting to false instead. | 2 | 129 | 0 | I have created a virtualenv using the --no-site-packages option and installed lots of libraries. Now I would like to revert the --no-site-packages option and use also the global packages.
Can I do that without recreating the virtualenv?
More precisely:
I wonder what exactly happens when creating a virtualenv using the --no-site-packages option as opposed to not using that option.
If I know what happens then I can figure out how to undo it. | Revert the `--no-site-packages` option with virtualenv | 1 | 0 | 0 | 22,256 |
3,371,136 | 2010-07-30T11:50:00.000 | 2 | 0 | 1 | 0 | python,virtualenv | 3,371,637 | 6 | false | 0 | 0 | Try adding a symlink between /virtualenv_root/lib/ and /path/to/desired/site-packages/ | 2 | 129 | 0 | I have created a virtualenv using the --no-site-packages option and installed lots of libraries. Now I would like to revert the --no-site-packages option and use also the global packages.
Can I do that without recreating the virtualenv?
More precisely:
I wonder what exactly happens when creating a virtualenv using the --no-site-packages option as opposed to not using that option.
If I know what happens then I can figure out how to undo it. | Revert the `--no-site-packages` option with virtualenv | 0.066568 | 0 | 0 | 22,256 |
3,371,255 | 2010-07-30T12:10:00.000 | 3 | 1 | 1 | 0 | python,unit-testing,testing | 3,371,690 | 7 | false | 0 | 0 | nosetests is a brilliant solution for unit testing in Python. It supports both unittest based testcases and doctests, and gets you started with it with just a simple configuration file. | 1 | 545 | 0 | I completed my first proper project in Python and now my task is to write tests for it.
Since this is the first time I did a project, this is the first time I would be writing tests for it.
The question is, how do I start? I have absolutely no idea. Can anyone point me to some documentation/ tutorial/ link/ book that I can use to start with writing tests (and I guess unit testing in particular)
Any advice will be welcomed on this topic. | Writing unit tests in Python: How do I start? | 0.085505 | 0 | 0 | 258,822 |
3,371,549 | 2010-07-30T12:51:00.000 | 0 | 0 | 0 | 0 | python,facebook,webkit,pyqt | 5,099,848 | 1 | true | 1 | 1 | I don't believe you can open an "authentication page" in a separate window under Facebook's terms (I used to work for Zynga, and we couldn't then, so I don't know how you'd achieve this now legally).
Second, you're looking into the QWebkit backwards I believe. From a UI perspective this is supposed to provide access to websites, and interact with them. If you want a good looking page, with all the bells and whistle, it pains me to say it ~ but use Actionscript 3, or Ajax and it's bundle.
This post would probably be answered better if tagged in the javascript, php, and as3 sections. As the php guys will know the correct hacks to get your intended result, if possible | 1 | 4 | 0 | Are there any examples how to authenticate your desktop Facebook application using PyQT and embedded webkit?
This is to provide better user experience than opening Facebook authentication page in a separate browser window. | pyqt, webkit and facebook authentication? | 1.2 | 0 | 0 | 640 |
3,371,795 | 2010-07-30T13:19:00.000 | 1 | 0 | 0 | 0 | python,sql-server,pyodbc,freetds | 3,372,035 | 2 | false | 0 | 0 | You could always just convert it to Decimal when it comes back... | 1 | 0 | 0 | I am connecting to an MS SQL Server db from Python in Linux. I am connecting via pyodbc using the FreeTDS driver. When I return a money field from MSSQL it comes through as a float, rather than a Python Decimal.
The problem is with FreeTDS. If I run the exact same Python code from Windows (where I do not need to use FreeTDS), pyodbc returns a Python Decimal.
How can I get back a Python Decimal when I'm running the code in Linux? | FreeTDS translating MS SQL money type to python float, not Decimal | 0.099668 | 1 | 0 | 1,284 |
3,372,444 | 2010-07-30T14:30:00.000 | 0 | 0 | 0 | 0 | python,numpy,memory-management,profile | 3,374,079 | 5 | false | 0 | 0 | Can you just save/pickle some of the arrays to disk in tmp files when not using them? That's what I've had to do in the past with large arrays. Of course this will slow the program down, but at least it'll finish. Unless you need them all at once? | 1 | 27 | 1 | I have a program that contains a large number of objects, many of them Numpy arrays. My program is swapping miserably, and I'm trying to reduce the memory usage, because it actually can't finis on my system with the current memory requirements.
I am looking for a nice profiler that would allow me to check the amount of memory consumed by various objects (I'm envisioning a memory counterpart to cProfile) so that I know where to optimize.
I've heard decent things about Heapy, but Heapy unfortunately does not support Numpy arrays, and most of my program involves Numpy arrays. | Profile Memory Allocation in Python (with support for Numpy arrays) | 0 | 0 | 0 | 4,821 |
3,372,774 | 2010-07-30T15:07:00.000 | 2 | 0 | 1 | 0 | python,multithreading | 3,372,837 | 2 | true | 1 | 0 | Usual approach for handling HTTP requests synchronously is to spawn (or re-use one in the pool) new thread for each request as soon as it comes.
However, python threads are not very good for HTTP, due to GIL and some i/o and other calls blocking whole app, including other threads.
You should look into multiprocessing module for this usage. Spawn some worker processes, and then pass requests to them to process. | 1 | 5 | 0 | I have never written any code that uses threads.
I have a web application that accepts a POST request, and creates an image based on the data in the body of the request.
Would I want to spin off a thread for the image creation, as to prevent the server from hanging until the image is created? Is this an appropriate use, or merely a solution looking for a problem ?
Please correct any misunderstandings I may have. | When to thread? | 1.2 | 0 | 0 | 189 |
3,374,542 | 2010-07-30T18:59:00.000 | 1 | 0 | 1 | 1 | python | 3,374,587 | 5 | false | 0 | 0 | Do you mean that you enter script directly into the interactive python shall, or are you executing your .py file from the terminal by running something like python myscript.py? | 1 | 10 | 0 | Every time I make a change to a python script I have to reload python and re-import the module. Please advise how I can modify my scripts and run then without having to relaunch python in the terminal.
Thanks. | Need to restart python in Terminal every time a change is made to script | 0.039979 | 0 | 0 | 16,071 |
3,374,943 | 2010-07-30T20:02:00.000 | 2 | 0 | 1 | 0 | python,twisted,multiprocessing | 3,379,621 | 2 | false | 0 | 0 | There are two dimensions to this question: concurrency and distribution.
Concurrency: either Twisted or multiprocessing will do the job of concurrently handling fetching/parsing jobs. I'm not sure though where your premise of the "Twisted overhead" comes from. On the contrary, the multiprocessing path would incur much more overhead, since a (relatively heavy-weight) OS-process would have to be spawned. Twisteds' way of handling concurrency is much more light-weight.
Distribution: multiprocessing won't distribute your fetch/parse jobs to different boxes. Twisted can do this, eg. using the AMP protocol building facilities.
I cannot comment on scrapy, never having used it. | 1 | 1 | 0 | Got a situation where I'm going to be parsing websites. each site has to have it's own "parser" and possibly it's own way of dealing with cookies/etc..
I'm trying to get in my head which would be a better choice.
Choice I:
I can create a multiprocessing function, where the (masterspawn) app gets an input url, and in turn it spans a process/function within the masterspawn app that then handles all the setup/fetching/parsing of the page/URL.
This approach would have one master app running, and it in turn creates multiple instances of the internal function.. Should be fast, yes/no?
Choice II:
I could create a "Twisted" kind of server, that would essentially do the same thing as Choice I. The difference being that using "Twisted" would also impose some overhead. I'm trying to evaluate Twisted, with regards to it being a "Server" but i don't need it to perform the fetching of the url.
Choice III:
I could use scrapy. I'm inclined not to go this route as I don't want/need to use the overhead that scrapy appears to have. As i stated, each of the targeted URLs needs its own parse function, as well as dealing with the cookies...
My goal is to basically have the "architected" solution spread across multiple boxes, where each client box interfaces with a master server that allocates the urls to be parsed.
thanks for any comments on this..
-tom | question comparing multiprocessing vs twisted | 0.197375 | 0 | 1 | 815 |
3,375,913 | 2010-07-30T22:48:00.000 | 1 | 0 | 1 | 0 | python | 28,681,111 | 4 | true | 0 | 0 | There are times you want to ask whether an object is an Exception (for example, when you get the result of a task back from a celery type process). You can do that using:
isinstance(x, Exception) | 1 | 1 | 0 | is there a function that will return true if some_function returns an error? | python: is there an isError function? | 1.2 | 0 | 0 | 22,717 |
3,376,252 | 2010-07-31T00:24:00.000 | 2 | 1 | 1 | 0 | php,python,c,types | 3,376,298 | 7 | false | 0 | 0 | Many a book has been written about this sort of thing. There's an inherent tradeoff; with a weakly-typed language a lot of annoyances simply cease to be. For instance, in Python you never have to worry about dividing a float by an int; adding an int to a list; typing functions' arguments (did you know, OCaml has special +. operators for adding floats because (+) sends ints to ints!); forgetting that a variable can be null... those sorts of problems simply vanish.
In their place come a whole host of new runtime bugs: Python's [0]*5 gives, wait for it, [0,0,0,0,0]! OCaml, for all the annoyance of strong typing, catches many many bugs with its compiler; and this is precisely why it's good. It's a tradeoff. | 3 | 17 | 0 | I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks? | What are the benefits (and drawbacks) of a weakly typed language? | 0.057081 | 0 | 0 | 11,418 |
3,376,252 | 2010-07-31T00:24:00.000 | 0 | 1 | 1 | 0 | php,python,c,types | 18,869,364 | 7 | false | 0 | 0 | You have to understand that PHP was created for the context of web applications. Everything in the context of the web is a string. Therefore it is very rare where strong typing would be beneficial. | 3 | 17 | 0 | I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks? | What are the benefits (and drawbacks) of a weakly typed language? | 0 | 0 | 0 | 11,418 |
3,376,252 | 2010-07-31T00:24:00.000 | 5 | 1 | 1 | 0 | php,python,c,types | 28,466,502 | 7 | false | 0 | 0 | I have been using both strong typed (like Java) and weak typed (like JavaScript) languages for some time now. What I have found is that the convenience of the weak typed languages are great for small applications. Unfortunately, as the application grows in size, it becomes impossible to manage. There becomes too much to keep track of in your head and you have to start depending on your IDE and the compiler more and more or your coding grinds to a halt. That is when strong typed languages start to become more useful - with the application grows very large.
Two examples that constantly drive me nuts in the weak typed JavaScript are using external libraries that are not thoroughly documented and refactoring.
External libraries: When dealing with a strongly typed language, the code from the library itself provides self documentation. When I create a variable of type Person, the IDE can inspect the code and tell there is a getFirstName(), getLastName() and getFullName(). In weak typed languages, this is not the case as a variable could be anything, have any kind of variable or function and have function arguments that could also be anything (they are not explicitly defined). As a result, a developer has to lean heavily on documentation, web searches, discussion forums and their memory of past usages. I find it can take hours of looking things up in JavaScript for external libraries while with Java I just hit the "." key and it pops up all my options with documentation attached. When you encounter libraries that are not 100% fully documented, it can be really frustrating with weak typed languages. I recently found myself asking "What is argument 'plot' in function 'draw'?" when using jqplot, a fairly well but not completely documented JavaScript library. I had to spend an hour or two digging through source code before finally giving up and finding an alternative solution.
Refactoring: With strongly typed languages, I find myself able to refactor quickly by just changing the file I need to change and then going to fix the compiler errors. Some tools will even refactor for you with a simple click of a button. With weak typed languages, you have to do a search and then replace with care and then test, test, TEST and then test some more. You are seldom entirely sure you have found and fixed everything you broke, especially in large applications.
For simple needs and small applications, these two concerns are minimal to non-existent. But if you are working with an application with 100's of thousands or millions of lines of code, weak typed languages will drive you nuts.
I think many developers get upset about this and turn it into an emotional discussion is because we sometimes get it in our heads that there is one right and one wrong approach. But each approach has its merits - its own advantages and disadvantages. Once you recognize that you set the emotion aside and choose the best for you for what you need right now. | 3 | 17 | 0 | I'm a big fan of PHP and it's obviously a very weakly-typed language. I realize some of the benefits include the general independence of changing variable types on the fly and such.
What I'm wondering about are the drawbacks. What can you get out of a strongly-typed language like C that you otherwise can't get from a weakly-typed one like PHP? Also with type setting (like double($variable)), one could argue that even a weakly-typed language can act just like a strongly-typed one.
So. Weak-type. What are some benefits I didn't include? More importantly, what are the drawbacks? | What are the benefits (and drawbacks) of a weakly typed language? | 0.141893 | 0 | 0 | 11,418 |
3,376,479 | 2010-07-31T02:08:00.000 | 0 | 0 | 0 | 0 | python,django,inheritance,inline,admin | 3,376,487 | 2 | false | 1 | 0 | All fields in the superclass also exist on the subclass, so having an explicit relation is unnecessary.
Model inheritance in Django is terrible. Don't use it. Python doesn't need it anyway. | 2 | 2 | 0 | Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles.
Intro
Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc.
Base Objects
So I have two base objects/models:
JournalEntry
JournalEntryItems
defined as follows:
class JournalEntry(models.Model):
gjID = models.AutoField(primary_key=True)
date = models.DateTimeField('entry date');
memo = models.CharField(max_length=100);
class JournalEntryItem(models.Model):
journalEntryID = models.AutoField(primary_key=True)
gjID = models.ForeignKey(JournalEntry, db_column='gjID')
amount = models.DecimalField(max_digits=10,decimal_places=2)
So far, so good. It works quite smoothly on the admin side (inlines work, etc.)
On to the next section.
We then have two more models
InvoiceEntry
InvoiceEntryItem
An InvoiceEntry is a superset of / it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site). That works quite smoothly too.
class InvoiceEntry(JournalEntry):
invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='')
journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID')
client = models.ForeignKey(Client, db_column='clientID')
datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid')
Where I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry. I'm getting the error:
<class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'>
The way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry. And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship.
Here's the code I'm using at the moment.
class InvoiceEntryItem(JournalEntryItem):
invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='')
invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID')
journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID')
I've tried removing the journalEntryItem OneToOneField. Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem).
I've also tried removing the invoiceEntry ForeignKey relationship. Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline. All I see are blank fields (instead of the actual data that is currently stored in the DB).
It seems like option 2 is closer to what I want to do. But my inexperience with Django seems to be limiting me. I might be able to filter the larger pool of journal entries to see just invoice entries. But it would be really handy to think of these solely as invoices (instead of a subset of journal entries).
Any thoughts on how to do what I'm after? | Django object extension / one to one relationship issues | 0 | 0 | 0 | 709 |
3,376,479 | 2010-07-31T02:08:00.000 | 1 | 0 | 0 | 0 | python,django,inheritance,inline,admin | 3,396,991 | 2 | true | 1 | 0 | First, inheriting from a model creates an automatic OneToOneField in the inherited model towards the parents so you don't need to add them. Remove them if you really want to use this form of model inheritance.
If you only want to share the member of the model, you can use Meta inheritance which will create the inherited columns in the table of your inherited model. This way would separate your JournalEntry in 2 tables though but it would be easy to retrieve only the invoices. | 2 | 2 | 0 | Howdy. I'm working on migrating an internal system to Django and have run into a few wrinkles.
Intro
Our current system (a billing system) tracks double-entry bookkeeping while allowing users to enter data as invoices, expenses, etc.
Base Objects
So I have two base objects/models:
JournalEntry
JournalEntryItems
defined as follows:
class JournalEntry(models.Model):
gjID = models.AutoField(primary_key=True)
date = models.DateTimeField('entry date');
memo = models.CharField(max_length=100);
class JournalEntryItem(models.Model):
journalEntryID = models.AutoField(primary_key=True)
gjID = models.ForeignKey(JournalEntry, db_column='gjID')
amount = models.DecimalField(max_digits=10,decimal_places=2)
So far, so good. It works quite smoothly on the admin side (inlines work, etc.)
On to the next section.
We then have two more models
InvoiceEntry
InvoiceEntryItem
An InvoiceEntry is a superset of / it inherits from JournalEntry, so I've been using a OneToOneField (which is what we're using in the background on our current site). That works quite smoothly too.
class InvoiceEntry(JournalEntry):
invoiceID = models.AutoField(primary_key=True, db_column='invoiceID', verbose_name='')
journalEntry = models.OneToOneField(JournalEntry, parent_link=True, db_column='gjID')
client = models.ForeignKey(Client, db_column='clientID')
datePaid = models.DateTimeField(null=True, db_column='datePaid', blank=True, verbose_name='date paid')
Where I run into problems is when trying to add an InvoiceEntryItem (which inherits from JournalEntryItem) to an inline related to InvoiceEntry. I'm getting the error:
<class 'billing.models.InvoiceEntryItem'> has more than 1 ForeignKey to <class 'billing.models.InvoiceEntry'>
The way I see it, InvoiceEntryItem has a ForeignKey directly to InvoiceEntry. And it also has an indirect ForeignKey to InvoiceEntry through the JournalEntry 1->M JournalEntryItems relationship.
Here's the code I'm using at the moment.
class InvoiceEntryItem(JournalEntryItem):
invoiceEntryID = models.AutoField(primary_key=True, db_column='invoiceEntryID', verbose_name='')
invoiceEntry = models.ForeignKey(InvoiceEntry, related_name='invoiceEntries', db_column='invoiceID')
journalEntryItem = models.OneToOneField(JournalEntryItem, db_column='journalEntryID')
I've tried removing the journalEntryItem OneToOneField. Doing that then removes my ability to retrieve the dollar amount for this particular InvoiceEntryItem (which is only stored in journalEntryItem).
I've also tried removing the invoiceEntry ForeignKey relationship. Doing that removes the relationship that allows me to see the InvoiceEntry 1->M InvoiceEntryItems in the admin inline. All I see are blank fields (instead of the actual data that is currently stored in the DB).
It seems like option 2 is closer to what I want to do. But my inexperience with Django seems to be limiting me. I might be able to filter the larger pool of journal entries to see just invoice entries. But it would be really handy to think of these solely as invoices (instead of a subset of journal entries).
Any thoughts on how to do what I'm after? | Django object extension / one to one relationship issues | 1.2 | 0 | 0 | 709 |
3,376,673 | 2010-07-31T03:34:00.000 | 1 | 0 | 0 | 0 | python,mysql,django | 3,377,350 | 2 | false | 1 | 0 | syncdb will not create a database for you -- it only creates tables that don't already exist in your schema. You need to:
Create a user to 'own' the database (root is a bad choice).
Create the database with that user.
Update the Django database settings with the correct database name, user, and password. | 1 | 0 | 0 | I set up Mysql5, mysql5-server and py26-mysql using Macports. I then started the mysql server and was able to start the prompt with mysql5
In my settings.py i changed database_engine to "mysql" and put "dev.db" in database_name.
I left the username and password blank as the database doesnt exist yet.
When I ran python manage.py syncdb, django raised an error
'django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)`
How do I fix this? Do I have to create the database first? is it something else? | Django MySql setup | 0.099668 | 1 | 0 | 5,039 |
3,377,038 | 2010-07-31T06:05:00.000 | 1 | 0 | 1 | 0 | python,screen-capture | 10,981,323 | 2 | false | 0 | 0 | I think the best way to do this would be create a higher level interface to ffmpeg. Unless you want to write the code to deal with X11 and record the screen, then it would be the best option.
If you test it on various platforms, then give useful error messages on things like incompatible sound systems, where to get certain video drivers, etc then this could be a pretty useful program. | 1 | 1 | 0 | I'm learning Python now and I want to develop a screen capture tool in Python.How I can do this work? | How I can develop a screen-capture tool in Python | 0.099668 | 0 | 0 | 1,288 |
3,377,439 | 2010-07-31T08:52:00.000 | 2 | 0 | 0 | 0 | python,qt,qt4,pyqt | 12,565,371 | 2 | false | 0 | 1 | setDefaultTextColor(col) "Sets the color for unformatted text to col." The documentation is not clear about what "unformatted text" means. I think it means: "all portions of the contents of the item that have not been styled."
The contents is a QTextDocument.
You style a part of a document using a QTextCursor. You can't style the QTextDocument per se, only a part that is selected by a QTextCursor (but you can select the whole document.)
You can style a QTextCursor using method mergeCharFormat(QTextCharFormat)
The QTextCharFormat has methods:
foreground().setColor(QColor)
setForeground(QBrush)
setTextOutline(QPen)
Foreground is a QBrush that paints several things including "text" (but better said: the fill of characters?)
One nuance is that certain newly constructed QBrush have (default to) QBrushStyle.NoBrush, which is transparent, even if you setColor(). | 1 | 10 | 0 | i have a scene with a multiple (QGraphicsTextItem)s, and i need to have control over their colors , so how to change a color of a QGraphicsTextItem ? is it possible anyway? i've been trying for 3 days until now . please help
thanks in advance | how to change the color of a QGraphicsTextItem | 0.197375 | 0 | 0 | 8,684 |
3,377,951 | 2010-07-31T11:50:00.000 | 2 | 0 | 0 | 1 | php,python,linux,server-push,publish-subscribe | 3,378,244 | 3 | false | 1 | 0 | If you know in advance you'll have a lot of subscribers (people/applications) that want notifications on a certain subject while on other hand you'll have few different subjects consider a pull technology anyway.
RSS, Atom are quite successful even though they use pull. The reason: no need to have an administration on the server of people who are subscribed, to detect who is no longer interested (client offline for a long time) or having a mechanism to get all the data out to the subscribers.
Using push, you need to do very little on the server, while the clients will only pull a small amount of data everytime.
Pull costs slightly more bandwidth that's cheap anyway while it saves you a lot on CPU and software maintanance which is quite expensive. | 1 | 3 | 0 | I would like to implement a mechanism which will provide a RESTful API that allows a client to register interest in a subject with a sever, and receive asynchronous notifications from the server after the interest is registered. In enterprise (messaging) architecture, this is known as publish/subscribe 'pattern'.
With desktop applications, this is readily acheivable - however with web applications, it is proving to be more difficult.
is there a (preferably open source) framework or library out there that allows the publish/subscribe pattern to be applied to web applications?.
Server side technology may be in any of the following languages: C, C++, PHP, Python, Ruby.
I am running on Linux Ubuntu 10.0.4 | A scalable solution for server side push? | 0.132549 | 0 | 0 | 651 |
3,379,032 | 2010-07-31T17:03:00.000 | 0 | 0 | 0 | 1 | python,deployment | 3,379,058 | 2 | false | 0 | 0 | How do people usually deploy such apps?
2 choices.
With instructions.
All bundled up.
You write simple instructions like this. Folks can follow these pretty reliably, unless they don't have enough privileges. Sometimes they need to sudo in linux environments.
Download easy_install (or pip)
easy_install this, easy_install that (or pip this, pip that)
easy_install whatever package you wrote.
It works really well. If you download some Python packages you'll see this in action.
Sphinx requires docutils. Django requires docutils and PIL. It works out really well to simply document the dependencies. Other folks seem to do it without serious problems. Follow their lead.
Bundling things up means you have to
(a) provide the entire original distribution (as required by most open source licenses)
(b) provide a compatible open source license with the licenses of the things you bundled. This can be easy if you depend on things that all of the same license. Otherwise, you basically can't redistribute them and have to resort to installation instructions. | 1 | 2 | 0 | I've written an app in python that depends on wxPython and some other python libraries. I know about pyexe for making python scripts executable on Windows, but what would be the easiest way to share this with my Mac using friends who wouldn't know how to install the required dependencies? One option would be to bundle my dependencies in the same package, but that seems kind of clunky. How do people usually deploy such apps? For once I miss Java... | Deploying python app to Mac and Windows users | 0 | 0 | 0 | 523 |
3,379,142 | 2010-07-31T17:37:00.000 | 3 | 0 | 1 | 0 | python,mysql | 3,380,170 | 2 | true | 0 | 0 | You can use the file command :
file `which python`
file `which mysql`
The file command is available on all UNIX-based systems. | 1 | 1 | 0 | How do I check if my python and mysql are 32 bit installations or 64 bit? | Python and MySQL compile version | 1.2 | 0 | 0 | 97 |
3,379,174 | 2010-07-31T17:43:00.000 | 3 | 1 | 1 | 0 | python,ruby,dynamic-languages | 3,379,213 | 7 | false | 0 | 0 | Learn [one of] these:
Ruby
Python
Clojure (a modern Lisp)
JavaScript (yes, this is a great dynamic language!)
Don't transition via a semi-dynamic, semi-Java language. Just jump in and try a dynamic language. In order to really understand what else is going on, you have to get out of the Java world by jumping in, not by sticking your toes into the water.
Yes, I know Clojure is on the JVM and that Ruby and Python have implementations on the JVM as well. But the runtime implementation of a language does not define the language. Learn the language, and you can pick a favorite runtime. | 4 | 0 | 0 | After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav | Which is the most preferred language to start with dynamic languages | 0.085505 | 0 | 0 | 367 |
3,379,174 | 2010-07-31T17:43:00.000 | 0 | 1 | 1 | 0 | python,ruby,dynamic-languages | 3,379,189 | 7 | false | 0 | 0 | Try Jython, if you like Java, this way you can both ;-) | 4 | 0 | 0 | After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav | Which is the most preferred language to start with dynamic languages | 0 | 0 | 0 | 367 |
3,379,174 | 2010-07-31T17:43:00.000 | 2 | 1 | 1 | 0 | python,ruby,dynamic-languages | 3,379,188 | 7 | false | 0 | 0 | Ahah, nice troll :) (with ruby and python tags).
In my humble opinion, after trying many languages, my favorite is Ruby with Ruby on Rails. | 4 | 0 | 0 | After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav | Which is the most preferred language to start with dynamic languages | 0.057081 | 0 | 0 | 367 |
3,379,174 | 2010-07-31T17:43:00.000 | 7 | 1 | 1 | 0 | python,ruby,dynamic-languages | 3,379,183 | 7 | false | 0 | 0 | Python is always fun.Go for it. | 4 | 0 | 0 | After working for on JAVA for a long time now i feel like also learn some other language just for a change. This time i want to spend some time learning and reading one of the dynamic languages.
Which is the most appropriate one that covers most of the features offered by dynamic languages and the syntax which probably is fun and also one that is closer to the syntax used by most of the dynamic languages.
BR,
Keshav | Which is the most preferred language to start with dynamic languages | 1 | 0 | 0 | 367 |
3,379,440 | 2010-07-31T19:01:00.000 | 3 | 0 | 0 | 0 | java,python,jakarta-ee | 3,379,488 | 4 | false | 1 | 0 | Any language/framework is a good choice, if it is used properly by competent developers. Sometimes the best choice is the one with which your team is most familiar.
Given your client space though, if you want to move to a "higher productivity" framework, I suggest Grails. Its implemented in Groovy, which Java developers can pick up naturally, and has various tools for generating wars, which can be deployed in your favorite servlet container. It takes a lot of the pain out of tradition J2EE development, as long as you follow the conventions. It has a ton of robust plugins for things like authentication/authorization. It will save you a ton of time. | 1 | 8 | 0 | Can Python be a good alternative to a web app that would otherwise be developed with Java EE? If so, which Python web app framework(s) may be a good choice? Please see details about the app below. I've asked a few people individually about this, who have worked for a good amount of time on either or both of Java EE and Python web apps, and got a few answers that indicated Python might not such a good choice, mainly due to ease of scaling, which is one of the needs. The other reason given was relative lack of Python developers in the part of the world where the app is being developed. We might be able to overcome the second one, but not sure about the first.
The app in question is a financial domain B2B one, with a few different types of users (as in: "actors" having different real-life roles - e.g. buyers, sellers), some admin users, will use an RDBMS, will have CRUD (Create/Read/Update/Delete) plus search functionality for master tables, some types of transactions involving both master and transaction tables, (with fairly straightforward, not very complex logic), and some reports to PDF for most / all of the search screens (queries). Around 80 or so features, where the features mostly map to screens in the app; not all, though. It will have a few types of batch jobs too, for which the plan is to run them at times when the users are not permitted to use the app. Will have JavaScript and AJAX on the front end. Will have the feature of sending emails to users, not just for signup or resetting passwords, but for transaction-related info as well. No programmatic reading of incoming emails though.
The aim is for it to eventually to get a medium level of scale in terms of numbers of (paying) users and transactions, not very high, but not too small a number - say in the range of 10,000 users, of which 2000 may be concurrently accessing the app in a time frame of 15 to 20 minutes. It will be a SaaS (Software as a Service) app.
I know the question is very general and open ended and I expect some answers on the lines of "It depends" :) but still want to get some views from people who have worked on such things.
Feel free to ask more questions if needed to answer. I'll answer them except for anything that is confidential.
Thanks.
Edit 1:
Really appreciate all the answers. I will take a little time to think about them, and then get back with further questions (original, or in response to answers) or comments, if any. | Can Python be good alternative for web app that would otherwise be done in Java EE? | 0.148885 | 0 | 0 | 1,841 |
3,379,971 | 2010-07-31T22:09:00.000 | 4 | 0 | 1 | 0 | python,math | 3,379,975 | 2 | false | 0 | 0 | You can do it with integer arithmetic:
items_per_page = 10
number_of_pages = (x + items_per_page - 1) // items_per_page | 1 | 5 | 0 | If I have 177 items, and each page has 10 items that means I'll have 18 pages.
I'm new to python and having used any of the math related functions.
How can I calculate 177/10 and then get round up so I get 18 and not 17.7 | Calculation to get page count based on # of items | 0.379949 | 0 | 0 | 1,287 |
3,380,986 | 2010-08-01T06:20:00.000 | 0 | 0 | 0 | 0 | python,user-interface,windows-xp,wxpython | 3,380,995 | 1 | false | 0 | 1 | If you have python win32 installed, then look under the directory <PYTHON>/lib/site-packages/win32comext/shell/demos/servers. This contains a file context_menu.py which has sample code for creating a shell extension.
Update: I think you want the folder_view.py sample. | 1 | 0 | 0 | I have a WxPython app that, among other things, has a integrated file-browser.
I want to be able to create a system-default file context menu (e.g. what you get if you right-click on a file in windows explorer) when a user right clicks on one of the items within my application.
Note: I already know how to create my own context menu (e.g. wx.EVT_LIST_ITEM_RIGHT_CLICK), I want the Windows context menu.
To clarify, I do not want, or need to modify the existing system context menu, I want to be able to display it for a specific file within my application.
Basically, I know what was right clicked on, and where the mouse pointer is (if it's needed). I want to create the system context menu there, just like it works in windows explorer. | Create Explorer.exe's File - Context Menu in WxPython application | 0 | 0 | 0 | 741 |
3,382,390 | 2010-08-01T14:36:00.000 | 2 | 0 | 0 | 0 | php,python,html,django | 3,382,449 | 2 | true | 1 | 0 | I see no problem with such setup, using lightweight frontend is recommended for django (or any other wsgi app) anyway. Although you should serve static html with nginx itself, not django. | 1 | 1 | 0 | I have a project coming up for client who is basically happy with how he manages his website. It's lots of HTML files (around 300 of them) that he insists on keeping flat HTML files so can easily edit and manage them using Dreamweaver. His site has a lot of traffic and so I'm looking into options of keeping things simple for him. He does insist on this method for the time being, I hope to win him around eventually. I'm slowly moving him off his expensive shared hosting package (he maxes it out constantly due to traffic) and getting him on a VPS so I have more control over what I can install and the resources are more flexible etc.
My issue is, there is some parts of the site that are in PHP. The small admin area he uses to do his newsletters for example sits separately away and he still requires this function. I'm thinking that since I'd have him on a server I can install what I like on, I want to start incorporating Django into the site. I'd much more prefer to do Django development for any admin type situation then trying to hack or make something with PHP. I know about the PHP frameworks out there, but they just don't appeal in this particular situation.
Due to this massive set of HTML files, is it possible to basically allow Django to carry on serving these up as they are... He can edit and upload them with Dreamweaver as he always has... But Django is 'there' for the admin side of it which he can do his newsletter? Eventually he is wanting translations for the pages and login for visitors (again which I'd like to do with Django) but for the time being I'm in this transitional period and wanting to do things step by step.
Aside note, he has a forum that is in PHP, which he also wants to keep... So I'm thinking a carefully setup combination of Nginx, FastCGI and Gunicorn so static, PHP and Django respectively can co-exist on the same server. Is this just foolish, or totally possible?
Any thoughts, guidance, tips or experience would be greatly appreciated so I take the best step forward. | Combining static HTML, a Django backend and a PHP forum on one server? | 1.2 | 0 | 0 | 1,097 |
3,382,739 | 2010-08-01T16:20:00.000 | 2 | 0 | 0 | 0 | python,sqlalchemy | 3,382,810 | 1 | true | 0 | 0 | Typical approach is to define all mappings in separate model module, with one file per class/table.
Then you just import needed classes whenever need them. | 1 | 1 | 0 | I had my sqlalchemy related code in my main() method in my script.
But then when I created a function, I wasn't able to reference my 'products' mapper because it was in the main() method.
Should I be putting the sqlalchemy related code (session, mapper, and classes) in global scope so all functions in my single file script can refer to it?
I was told a script is usually layout out as:
globals
functions
classes
main
But if I put sqlalchemy at the top to make it global, I have to move my classes to the top also. | Where to put my sqlalchemy code in my script? | 1.2 | 1 | 0 | 87 |
3,384,361 | 2010-08-02T00:56:00.000 | 1 | 0 | 1 | 0 | python,python-3.x,python-2.x | 3,401,516 | 4 | false | 0 | 0 | Things like changing default floor
division could be a real pain to
change for big projects.
If you had started making the change 8 years ago when Python 2.2 was introduced with // and from __future__ import division, it wouldn't be a pain now. Personally, I'm glad to finally get rid of old-style division!
My second-favorite feature of Python 3.x is the str/bytes distinction. Besides making Unicode support easier, bytes is far more convenient for database BLOBs than buffer was. | 1 | 8 | 0 | I learned Python as my first serious (non BASIC) language about 10 years ago. Since then, I have learned lots of others, but I tend to 'think' in Python. When I look at the list of changes I do not see one I need this feature. I usually say to myself, hmm that would been a good way of doing it, but why change it now?
Things like changing the default floor division could be a real pain to change for big projects. It seems like the major players are dragging their feet. What is the key feature that would make me want to invest in another learning curve? | Why is Python 3 (or later) better than Python 2? | 0.049958 | 0 | 0 | 1,312 |
3,384,374 | 2010-08-02T01:00:00.000 | 28 | 0 | 1 | 0 | python,class,inheritance | 3,386,914 | 3 | true | 0 | 0 | Mostly it isn't going to matter whether or not you inherit from object, but if you don't there are bugs waiting to catch you out when you've forgotten that you decided not to bother.
Some subtle things just won't work properly if you don't ultimately inherit from object:
Using properties in classic classes only partly works: get works alright, but set does weird things.
Multiple inheritance behaves differently in classic classes than in classes derived from object.
Also multiple inheritance won't work if you try to mix classic classes with those that subclass object. Whatever you do you want to be consistent.
Some people are fine with continuing to use classic classes except when they need the new behaviour, others say to always use new style classes to avoid later shooting yourself in the foot. If you're working on a single person project do whatever is good for you; if its a shared project be consistent with the other developers. | 1 | 34 | 0 | So I'm just learning python (I know plenty of other languages) and I'm confused about something. I think this is due to lack of documentation (at least that I could find). On a few websites, I've read that you should derive your classes from object:
class Base(object):
pass
But I don't see what that does or why or when you should do it. Is there official documentation on this that I've missed? Is this a 3.x feature? | Deriving class from `object` in python | 1.2 | 0 | 0 | 11,827 |
3,384,989 | 2010-08-02T04:28:00.000 | 6 | 0 | 1 | 0 | .net,ironpython,optional-parameters,named-parameters | 3,401,635 | 2 | true | 0 | 1 | Named and optional parameters are fully supported. .NET has had these for a long time for VB.NET support and so IronPython has supported that same way to do them since the beginning. The new C# syntax maps to the same underlying metadata as the old VB support.
For calling you use f(x = 42) which is Python's named parameter syntax. For optional parameters you can just leave them out. In your example case you can probably do Draw(weight, height) and leave Area out. Or you can call w/ weight and height as named parameters and leave Area out.
The underlying .NET meta data that IronPython looks for is either the OptionalAttribute or DefaultParameterValueAttribute. For optional we pass in default(T) unless the type is object in which case we pass in Missing.Value. This generally matches how reflection calls these APIs as well. | 1 | 3 | 0 | I hope to load .net dll in ironpython.
But one of static functions in .net dll, has some Named and Optional Arguments.
like, Draw(weight:w,height:h, Area=1)
Only can I use full arguments? | Can I use Named and Optional Arguments in ironpython | 1.2 | 0 | 0 | 1,159 |
3,385,013 | 2010-08-02T04:35:00.000 | 0 | 0 | 1 | 0 | python,linux,pyqt4,kubuntu | 3,460,599 | 2 | false | 0 | 1 | I guess you need python-qt4 qt4-designer qt4-dev-tools. | 1 | 2 | 0 | Im planing to do some GUI development using pyqt4 pykde and python3.1 on Kubuntu 10.4. In the research I did I found out that most of the things are available as packages in repositories and some of the packages are preinstalled. Only thing is I'm not able to figure out what to install and what not to. Can someone please give me a list of packages that I need to install to do GUI development using python3.1 pyQt4 and pyKDE. | pyqt installation question | 0 | 0 | 0 | 333 |
3,385,400 | 2010-08-02T06:08:00.000 | 0 | 0 | 0 | 0 | python,django,csv | 3,389,840 | 5 | false | 1 | 0 | Depending upon the data format (you said CSV) and the database, you'll probably be better off loading the data directly into the database (either directly into the Django-managed tables, or into temp tables). As an example, Oracle and SQL Server provide custom tools for loading large amounts of data. In the case of MySQL, there are a lot of tricks that you can do. As an example, you can write a perl/python script to read the CSV file and create a SQL script with insert statements, and then feed the SQL script directly to MySQL.
As others have said, always drop your indexes and triggers before loading large amounts of data, and then add them back afterwards -- rebuilding indexes after every insert is a major processing hit.
If you're using transactions, either turn them off or batch your inserts to keep the transactions from being too large (the definition of too large varies, but if you're doing 1 million rows of data, breaking that into 1 thousand transactions is probably about right).
And most importantly, BACKUP UP YOUR DATABASE FIRST! The only thing worse than having to restore your database from a backup because of an import screwup is not having a current backup to restore from. | 3 | 4 | 0 | What would be the best way to import multi-million record csv files into django.
Currently using python csv module, it takes 2-4 days for it process 1 million record file. It does some checking if the record already exists, and few others.
Can this process be achieved to execute in few hours.
Can memcache be used somehow.
Update: There are django ManyToManyField fields that get processed as well. How will these used with direct load. | Django with huge mysql database | 0 | 0 | 0 | 2,045 |
3,385,400 | 2010-08-02T06:08:00.000 | 3 | 0 | 0 | 0 | python,django,csv | 3,385,550 | 5 | false | 1 | 0 | I'm not sure about your case, but we had similar scenario with Django where ~30 million records took more than one day to import.
Since our customer was totally unsatisfied (with the danger of losing the project), after several failed optimization attempts with Python, we took a radical strategy change and did the import(only) with Java and JDBC (+ some mysql tuning), and got the import time down to ~45 minutes (with Java it was very easy to optimize because of the very good IDE and profiler support). | 3 | 4 | 0 | What would be the best way to import multi-million record csv files into django.
Currently using python csv module, it takes 2-4 days for it process 1 million record file. It does some checking if the record already exists, and few others.
Can this process be achieved to execute in few hours.
Can memcache be used somehow.
Update: There are django ManyToManyField fields that get processed as well. How will these used with direct load. | Django with huge mysql database | 0.119427 | 0 | 0 | 2,045 |
3,385,400 | 2010-08-02T06:08:00.000 | 0 | 0 | 0 | 0 | python,django,csv | 4,772,823 | 5 | false | 1 | 0 | Like Craig said, you'd better fill the db directly first.
It implies creating django models that just fits the CSV cells (you can then create better models and scripts to move the data)
Then, db feedding : a tool of choice for doing this is Navicat, you can grab a functional 30 days demo on their site. It allows you to import CSV in MySQL, save the importation profile in XML...
Then I would launch the data control scripts from within Django, and when you're done, migrating your model with South to get what you want or , like I said earlier, create another set of models within your project and use scripts to convert/copy the data. | 3 | 4 | 0 | What would be the best way to import multi-million record csv files into django.
Currently using python csv module, it takes 2-4 days for it process 1 million record file. It does some checking if the record already exists, and few others.
Can this process be achieved to execute in few hours.
Can memcache be used somehow.
Update: There are django ManyToManyField fields that get processed as well. How will these used with direct load. | Django with huge mysql database | 0 | 0 | 0 | 2,045 |
3,385,990 | 2010-08-02T07:59:00.000 | 2 | 1 | 0 | 0 | python,twitter | 3,388,478 | 1 | true | 0 | 0 | Twitter's API is over HTTP, which is a stateless protocol. you don't really need to close the connection, since connections made and closed for each request | 1 | 1 | 0 | i developed an aplication built on twitter api , but i get erorrs like a mesage that i've parsed and deleted to be parsed again at the next execution , could that be because i left the twitter connection opened or is just a fault of the twitter API. I also tried to delete all direct messages because it seemed too full for me but instead the Api has just reset the count of my messages , the messages haven't been deleted:(( | twitter connection needs to be closed? | 1.2 | 0 | 1 | 105 |
3,386,098 | 2010-08-02T08:20:00.000 | 0 | 0 | 0 | 0 | python,user-interface,tkinter,ttk | 3,389,225 | 2 | false | 0 | 1 | I've never used these widgets so I have no idea how possible this is, but what I would try is something akin to the grid_remove() method. If you can move the tabs to an invisible widget, or just make them invisible without losing content, that's what I'd look for/try. | 2 | 1 | 0 | I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows).
I thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see.
Edit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place. | Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs) | 0 | 0 | 0 | 1,350 |
3,386,098 | 2010-08-02T08:20:00.000 | 2 | 0 | 0 | 0 | python,user-interface,tkinter,ttk | 3,650,157 | 2 | true | 0 | 1 | The notebook widget doesn't do scrolling of tabs (or multiple layers of them either) because the developer doesn't believe that they make for a good GUI. I can see his point; such GUIs tend to suck. The best workaround I've seen is to have a panel on the side that allows the selection of which pane to display. You can then apply tricks to that panel to manage the amount of information there (e.g., by making it a treeview widget and holding the info hierarchically, much like most email clients handle mail folders; treeview widgets are scrollable). | 2 | 1 | 0 | I'm working on a project using Tkinter and Python. In order to have native theming and to take advantage of the new widgets I'm using ttk in Python 2.6. My problem is how to allow the user to scroll through the tabs in the notebook widget (a la firefox). Plus, I need a part in the right edge of the tabs for a close button. The frame for the active tab would need to fill the available horizontal space (including under the scroll arrows).
I thought I could do this using the Place geometry manager, but I was wondering if there was a better way? The ttk python docs don't have any methods to deal with this that I could see.
Edit: looks like there are difficulties for even trying to implement this using place. For one, I'd still need the tabs to scroll and the active panel to stay in the one place. | Using the ttk (tk 8.5) Notebook widget effectively (scrolling of tabs) | 1.2 | 0 | 0 | 1,350 |
3,386,377 | 2010-08-02T09:07:00.000 | 3 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,409 | 9 | false | 0 | 1 | First, results speak for themselves: if you can piece together another version of one of your applications in pyqt, and tell him how long it took, it might be motivation enough.
Or, next time you're starting a project, you could prototype four or five different versions of the interface in pyqt in the morning, ask his feedback after lunch, and then say, "if I keep going on these, it'll be done in two days; if I redo this in netbeans, it'll be done in four."
And as for the "never heard of it", feel free to point out that Google uses python extensively, and even hired many of the python developers. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.066568 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 0 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,403 | 9 | false | 0 | 1 | Just use Netbeans as an IDE and he'll never notice :P
Speaking more seriously: a side by side comparison of strong and weak points behind each of technologies will certianly be more convincing. Just don't cheat too much in favor of Python ;) | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 12 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,436 | 9 | true | 0 | 1 | If your selling skills are not working in discussion format I highly suggest that you document it. Some managers/bosses really respond well to this.
Make a matrix of all the metrics that you yourself use to grade the two frameworks (I leave the level of objectivity to you there: for example if objective it should analyze the cost of transition and the loss of institutional experience; but it might not be high).
Finally, send it by e-mail and viola you have:
made a report/analysis of the situation providing options for improvement
this shows that you are thinking towards future and that you show initiative
EDIT:
You can also ask your boss to show your analysis to his friend if he trust his friend that much, but ask for a written counter-analysis so that you can address the critique.
It is a good thing to do it openly and document the decision process well, since ultimately, if your suggestion is accepted, you will share responsibility for the decision. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 1.2 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 1 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,699 | 9 | false | 0 | 1 | Perhaphs showing him
a)Time spent in developing in Python and Java
b)lines of code in Python and Java
with these two metrics maybe you can make your case stronger | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.022219 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 5 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,477 | 9 | false | 0 | 1 | The basic problem here is that your non-technical boss is getting conflicting advice from you and from the friend who advised him in the first place. If you want him to take your advice seriously you need to prove that your advice is likely to be trustworthy. And that will only come with taking the lead and being successful with significant projects in the company. Right now, you haven't earned his confidence.
The other thing to consider is how your preferences mesh with the company's objectives. For instance, you want to be able to write code fast. But the boss / the company needs code that is going to be reliable and maintainable ... if you decide to take another position. He doesn't want to be left in the awkward situation where the company is contractually committed to deliver code that doesn't really work properly, and the only person who understands it has left. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.110656 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 1 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,387,150 | 9 | false | 0 | 1 | I would guess a lot, in terms of risk management, would depend on the separation/isolation of the various softwares you develop, and their life cycle.
If you don't need to further a central set of libraries, or have (or can develop) Python bindings for those, and the projects are relatively self contained, say a turn around of two to six months, you could give him a quote for a project in Java that is reasonable and he's familiar with (to make sure it doesn't appear artificially inflated). Then give a much reduced quote for the same in py+pyQt, and see if you can get him to invest on your advice.
Without tangible evidence coming from inside that a change in route will bring benefit the more management and economics savvy people who are technically ignorant will not buy into a new platform when the old one never prevented from realizing and selling.
Without a decent assessment of why he doesn't want to switch platform and what he considers risks it's kinda hard to give more pertinent advice. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.022219 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 1 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,396 | 9 | false | 0 | 1 | Have you emphasised the point of the lower development time. Any person that doesn't want a shorter turn around time is an idiot. This is the only main issue i can think for the change. Or what you could do is develop it on the side and when you have errors say this is what i have been doing in my spare time(have a working copy written in python). | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.022219 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 8 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,386,487 | 9 | false | 0 | 1 | The problem is that development time is usually nothing compared to maintenance. Who cares if it takes two days instead of four if the app has a 1-5 year lifetime?
You'll have to convince him that if you get hit by a truck or leave the company (perhaps to work for somebody who uses Python exclusively) that he won't be left in the lurch with a bunch of applications that nobody else knows and can't maintain or upgrade. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 1 | 0 | 0 | 874 |
3,386,377 | 2010-08-02T09:07:00.000 | 2 | 0 | 0 | 0 | java,python,netbeans,pyqt | 3,387,872 | 9 | false | 0 | 1 | Some people will tell you to try to convince your boss verbally. Others will tell you to document the time savings you think you can make. My opinion is that you just go ahead and do it. Do it in your own time if you strongly believe its in your best interests.
I'm yet to meet a software manager who turned down a working piece of software when it comes in on time and under budget. This is by far the best method of persuasion I've used in my career. Its also a great way to show you have initiative. Just be prepared to work for free if it doesnt work out. | 9 | 5 | 0 | I'm working for small company, which operates in the automation industry.
The boss hired me because he wants to sell/give some desktop applications to his
current costumers.
He imposes me to use the Netbeans Platform (a generic desktop application framework).
A software engineer friend of his advised him to choose this framework.
At the moment I created 3 desktop applications with Netbeans Platform.
I like Netbeans Platfom. I really take advantage of modularity, Window System and Lookup.
Unfortunately I'm frustrated to known that I can do the same works with Python and PyQt in a fraction of time.
I've already illustrated to my boss the main advantages of Python, but he doesn't like the
idea to use a language that he never heared of it.
I'm the only programmer who codes desktop applications. And except the framework imposition, I'm free to use whatever I want.
I'm looking for good motivations to convince him to leave Netbeans Platform for Python/PyQt.
P.S: My english is bad, sorry. | How to convince boss to substitute Java/Netbeans Platform for Python/PyQt? | 0.044415 | 0 | 0 | 874 |
3,387,605 | 2010-08-02T12:15:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,command-prompt | 3,388,313 | 1 | false | 1 | 0 | You can run appcfg.py with --no_cookies to tell it not to store authentication cookies, or -e EMAIL to specify an email address that differs from the one in the current cookie. | 1 | 1 | 0 | I am uploading google app engine application with the help of appcfg.py command from command prompt in windows.
But after one login I want to upload another application from the same command prompt but i cannot because this second application has no rights with the current login so i want to logout from this session on command prompt so for that what to do? It is a python application
Is there any command to logout from command prompt? | logout from command prompt to uploading application on google app | 0.53705 | 0 | 0 | 556 |
3,387,663 | 2010-08-02T12:20:00.000 | 4 | 1 | 0 | 0 | c++,python,swig | 3,393,617 | 3 | true | 0 | 1 | It looks like you aren't linking to the Python runtime library. Something like adding -lpython24 to your gcc line. (I don't have a Linux system handy at the moment). | 1 | 2 | 0 | HI all
I am trying to use SWIG to export C++ code to Python.
The C sample I read on the web site does work but I have problem with C++ code.
Here are the lines I call
swig -c++ -python SWIG_TEST.i
g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/
gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc++
When I am finished I receive the following error message
ImportError: ./_SWIG_TEST.so: undefined symbol: Py_InitModule4
Do you know what it is? | using SWIG with C++ | 1.2 | 0 | 0 | 886 |
3,388,829 | 2010-08-02T14:43:00.000 | 2 | 0 | 0 | 0 | php,python,backend | 3,388,948 | 2 | false | 1 | 0 | A "Python backend" is simply server-side software written in Python, no different in general terms than server-side software written in PHP. It does all the same things, just with a different programming language. | 2 | 1 | 0 | I am primarily a PHP developer, and I have been browsing the source code of a few open-source applications recently(Mozilla Bespin in particular), to find that some of them use a Python "back-end." I was just wondering what the purpose of this back-end is. I am assuming it is the same thing as the model in an MVC framework and is used to interface with the database, but I'm unsure. If I'm right and the back-end is used to simply interface with the database, is the sqlite/mysql server included in the backend, because I didn't see any database config information in the install directions? | What purpose does a python backend serve? | 0.197375 | 0 | 0 | 4,068 |
3,388,829 | 2010-08-02T14:43:00.000 | 1 | 0 | 0 | 0 | php,python,backend | 3,388,977 | 2 | false | 1 | 0 | It looks like Bespin uses Python in the same way it would use PHP, if the autors chose PHP and not Python.
If you are a PHP developer, you already are a "back-end" programmer and you already know what it does, the only difference is the programming language that was used to do that.
Some web sites, mostly the huge ones like Facebook or Twitter, consist of more layers than the usual MVC ones. If you look at Facebook, you can see PHP scripts that generate HTML and AJAX responses as the "front-end" and high-performance databases, storage, computation cluster, application servers etc. as the "back-end" (where PHP is rarely used). So what is considered "front-end" and what "back-end" may also depend on how you look at it. | 2 | 1 | 0 | I am primarily a PHP developer, and I have been browsing the source code of a few open-source applications recently(Mozilla Bespin in particular), to find that some of them use a Python "back-end." I was just wondering what the purpose of this back-end is. I am assuming it is the same thing as the model in an MVC framework and is used to interface with the database, but I'm unsure. If I'm right and the back-end is used to simply interface with the database, is the sqlite/mysql server included in the backend, because I didn't see any database config information in the install directions? | What purpose does a python backend serve? | 0.099668 | 0 | 0 | 4,068 |
3,388,911 | 2010-08-02T14:53:00.000 | 0 | 1 | 0 | 0 | python,linux,ipv6 | 3,388,966 | 3 | false | 0 | 0 | You could just simply run 'ifconfig' with a subprocess.* call and parse the output. | 1 | 6 | 0 | Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.
Thanks. | How to get the IPv6 address of an interface under linux | 0 | 0 | 1 | 3,133 |
3,389,313 | 2010-08-02T15:40:00.000 | 1 | 0 | 1 | 0 | python,import | 3,389,337 | 1 | true | 0 | 0 | Use imp.find_module() and imp.load_module()
find_module lets you specify your own path to search | 1 | 1 | 0 | I have an executable file, named, for example, resource.py. It is disposed in the folder named resource. Renaming file or folder is objectionable - it is old product and users accustomed to use such naming. At old version it was under another project, so imports to it sound like import main_product.resource.<..>.
Now I need to use imports like import resource.<..> and __import__('resource.<..>', ...). Then I try it, I get an expected error, because Python try to import from the file resource.py first.
Suggestion solutions:
remove path of current folder from sys.path:
we need an ugly chunk of code at the begin of the file;
no relative imports will be available in this folder;
put folder path at the end sys.path list:
bigger chunk of ugly code at the begin of the file;
i am not sure that this feature will always work perfect.
Have any usable idea about this?
P.S. Python v2.6, FreeBSD 7.3 | Importing from module with the same name as executable file in Python | 1.2 | 0 | 0 | 560 |
3,390,558 | 2010-08-02T18:15:00.000 | 0 | 0 | 1 | 1 | python | 13,340,272 | 5 | false | 0 | 0 | I had the same error due to the fact that Python2.7 was not on the path used by sudo.
I just added:
alias sudo='sudo env PATH=$PATH'
before running the installer. | 1 | 7 | 0 | A newbie question but.....
I've installed python2.7 on a host where the system version is 2.3 (2.7 at ~/python2.7/bin/python). I'd like to add a few packages such as MySQLdb but need setuptools.
The directions say that you can use --prefix as an argument. However, if I do the following:
sh setuptools-0.6c11-py2.7.egg --prefix=~/python2.7/bin/python
I get the error msg:
-bash-3.00$ sh setuptools-0.6c11-py2.7.egg --prefix=~/python2.7/bin/python
setuptools-0.6c11-py2.7.egg: line 3: exec: python2.7: not found
Am I not using the --prefix command correctly? Naturally, typing sh setuptools-0.6c11-py2.7.egg --help can't find python either.
How do I tell setuptools where to find python explicitly? Any other issues I need to be aware of? | Installing setuptools in a private version of python | 0 | 0 | 0 | 12,097 |
3,390,778 | 2010-08-02T18:44:00.000 | 0 | 0 | 1 | 0 | python,vba,compiler-construction | 10,985,685 | 4 | false | 0 | 0 | [PyScripter](http://code.google.com/p/pyscripter/"This is the download page.") is good and is actively developed. | 2 | 1 | 0 | does anyone know if there a vba style compiler/gui for python. i am using the regular IDLE and it is difficult to navigate from function to function. with the VBA editor you are able to skip from function to function with a listbox. does anyone know if such a thing exists for python? | vba-style compiler/gui for python | 0 | 0 | 0 | 252 |
3,390,778 | 2010-08-02T18:44:00.000 | 1 | 0 | 1 | 0 | python,vba,compiler-construction | 3,390,840 | 4 | true | 0 | 0 | Learn a decent text editor, and learn it well.
In vim for instance, I would search for def func and get there WAY faster than you ever could using your mouse in a drop-down list. | 2 | 1 | 0 | does anyone know if there a vba style compiler/gui for python. i am using the regular IDLE and it is difficult to navigate from function to function. with the VBA editor you are able to skip from function to function with a listbox. does anyone know if such a thing exists for python? | vba-style compiler/gui for python | 1.2 | 0 | 0 | 252 |
3,391,013 | 2010-08-02T19:16:00.000 | 4 | 0 | 1 | 0 | python,introspection | 3,391,039 | 2 | true | 0 | 0 | help(thing) pretty prints all the docstrings that are in the module, method, whatever ... | 1 | 7 | 0 | Is there is a tool similar to dir() for modules that will tell me what parameters a given function takes? For instance, I would like to do something like dir(os.rename) and have it tell me what parameters are documented so that I can avoid checking the documentation online, and instead use only the Python scripting interface to do this. | Python introspection: description of the parameters a function takes | 1.2 | 0 | 0 | 4,945 |
3,391,222 | 2010-08-02T19:49:00.000 | 1 | 1 | 0 | 0 | python,flash,video-capture,html5-video | 3,393,137 | 1 | true | 1 | 0 | There are many video solutions. Here are two:
Take a look at Flash Media Server (FMS). You will need to some server-side code to place the video into a folder as it streams up.
Also, if you're looking into free open-source take a look at Red5. | 1 | 1 | 0 | I wanted to make a website that would let users record a small video message through their broswer and save it to my website.
As I have never used flash, i wanted to know what softwares would be required and what programming languages would I need? I mean, what should I go about learning to implement such a site. I would prefer open-source solutions wherever possible.
Can something like this be implemented using python and html5? | Flash video record on website tutorial | 1.2 | 0 | 0 | 549 |
3,391,368 | 2010-08-02T20:11:00.000 | 0 | 0 | 0 | 0 | python | 3,391,404 | 1 | true | 1 | 0 | Fixed it. Sorry Santa for not including the console print out. Windows was dumb and added an extra .py to the file when I created it. So everything was actually "pythonfile.py.py". Awesome. | 1 | 0 | 0 | I added a folder to my PYTHONPATH where I can put all of my Django Apps. I print sys.path, and everything looks good, the folder I want is there. However, when I go to import a module, it tells me that there's no module by that name. All the site-packages modules work fine. In all of my Django apps, there's an "_____init_____.py" like there's supposed to be. I heard that if those are created on windows there can be problems, but I couldn't dig up much more than that. | Python Path import problems | 1.2 | 0 | 0 | 252 |
3,391,558 | 2010-08-02T20:40:00.000 | 3 | 0 | 0 | 0 | python,image | 3,391,578 | 3 | false | 0 | 0 | Look at PyMagick, the python interface for the ImageMagick libraries. It's fairly simple to resize an image, retaining proportion, while limiting the longest side.
edit: when I say fairly simple, I mean you can describe your resize in terms of the longest acceptable values for each side, and ImageMagick will preserve the proportions automatically. | 1 | 1 | 0 | I want to create a thumbnail, and the width has to be either fixed or no bigger than 200 pixels wide (the length can be anything).
The images are either .jpg or .png or .gif
I am using python.
The reason it has to be fixed is so that it fits inside a html table cell. | Need to create thumbnail, how to ensure proportions and set fixed width? | 0.197375 | 0 | 0 | 405 |
3,391,692 | 2010-08-02T20:58:00.000 | 1 | 1 | 1 | 0 | python,objective-c,unicode,pyobjc | 3,391,733 | 1 | true | 0 | 0 | I misread the documentation. I need to do this:
NSWorkspace.sharedWorkspace().setIcon_forFile_options_(NSImage.alloc().initWithContentsOfFile_(icon),target,0)
Unfortunately the error is what confused me. | 1 | 0 | 0 | I have this line:
NSWorkspace.sharedWorkspace().setIcon_forFile_options_(unicode(icon),unicode(target),0)
Why does it give that error and how do I fix it?
Thank you. | PyObjC giving strange error - [OC_PythonUnicode representations]: unrecognized selector sent to instance 0x258ae2a0 | 1.2 | 0 | 0 | 318 |
3,391,920 | 2010-08-02T21:28:00.000 | 2 | 0 | 1 | 1 | python | 3,391,956 | 2 | false | 0 | 0 | Yes you can. Is this a hard thing to test yourself? | 1 | 2 | 0 | if I run a .py script, can I open a new terminal, modify the file and run it also?
i.e. does the file that I run get loaded in memory, such that I can modify the file and run it at the same time in a different terminal? | if I run a .py script, can I open a new terminal, modify the file and run it also? | 0.197375 | 0 | 0 | 146 |
3,392,203 | 2010-08-02T22:10:00.000 | 2 | 0 | 1 | 1 | linux,kernel,init,python | 3,392,306 | 2 | false | 0 | 0 | I don't think init needs to be a C binary; it can be a script with a #! at the beginning; if that is the case, then you can have it be a python program with little effort.
Having said that, it is pretty trivial to write an inittab where init just runs a single program once (Although it's usually more useful to do other stuff too).
Given that you will probably want to do some things on your system which can't easily be done with python (for example, try mounting filesystems without a "mount" binary), you will probably need a busybox (for example) anyway; adding "init" to a busybox binary increases its size very little. | 1 | 3 | 0 | Would it be possible and not incredibly difficult to build a linux kernel, with a python interpreter built in or accessible from the kernel, that could run a python file as it's init process? | Linux kernel that runs python file for init | 0.197375 | 0 | 0 | 1,752 |
3,392,333 | 2010-08-02T22:34:00.000 | 4 | 0 | 0 | 1 | python,fabric | 5,531,404 | 4 | true | 0 | 0 | If you don't want to have to iterate through all open connections, fabric.network.disconnect_all() is what you're looking for. The docstring reads
"""
Disconnect from all currently connected servers.
Used at the end of fab's main loop, and also intended for use by library users.
""" | 1 | 6 | 0 | The website says:
Closing connections: Fabric’s
connection cache never closes
connections itself – it leaves this up
to whatever is using it. The fab tool
does this bookkeeping for you: it
iterates over all open connections and
closes them just before it exits
(regardless of whether the tasks
failed or not.)
Library users will need to ensure they
explicitly close all open connections
before their program exits, though we
plan to makes this easier in the
future.
I have searched everywhere, but I can't find out how to disconnect or close the connections. I am looping through my hosts and setting env.host_string. It is working, but hangs when exiting. Any help on how to close? Just to reiterate, I am using the library, not a fabfile. | Disconnecting from host with Python Fabric when using the API | 1.2 | 0 | 0 | 4,881 |
3,393,314 | 2010-08-03T02:57:00.000 | 2 | 0 | 0 | 0 | python,windows,passwords,download | 3,393,326 | 2 | false | 0 | 0 | This is best implemented at the web server level.
If you are using Apache, this can be done by placing the files you desire to protect in a directory with an htaccess file which requires user authentication.
Then, implement HTTP Basic Auth in your Python script to download the files. Make sure to use an SSL connection; basic auth sends the user's password over the wire in the clear. | 1 | 0 | 0 | I am working on a project that requires password protected downloading, but I'm not exactly sure how to implement that. If the target file has a specific extension (.exe, .mp3, .mp4, etc), I want to prompt the user for a username and password. Any ideas on this?
I am using Python 26 on Windows XP. | Prevent A User From Downloading Files from Python? | 0.197375 | 0 | 0 | 450 |
3,394,757 | 2010-08-03T08:16:00.000 | 1 | 0 | 1 | 0 | python,if-statement | 3,394,782 | 11 | false | 0 | 0 | Try a simple game, like if you press 'L', turn left, if you press 'R', turn right, if there's a monster, you die etc. | 4 | 11 | 0 | What would be a good set of programming exercises that would help Python newbies to learn the use of the "if ... else" construct? I could cook up the following, do you know of any more?
Find the largest/smallest of three numbers.
Given a date (year, month, day), find the next date.
Most of the intended audience have not had much of an exposure to programming before, and I am keen on getting them used to thinking correctly about "if ... else" (and all the rest of it, in due course). | What are good programming questions to exercise the use of "if ... else" in Python? | 0.01818 | 0 | 0 | 14,476 |
3,394,757 | 2010-08-03T08:16:00.000 | 9 | 0 | 1 | 0 | python,if-statement | 3,394,792 | 11 | false | 0 | 0 | "Figure out whether a given year is a leap year" springs to mind almost immediately. Just give 'em the rules and turn 'em loose.
Other possibilities (albeit with stuff other than if statements):
Hunt the Wumpus (you may have to google for this one, I'm showing my age).
The perennial "detect a win in a Tic Tac Toe (Noughts and Crosses) game" (you could do this with eight if statements if you don't want a loop).
Guessing a number between 1 and 100 as quickly as possible (higher, lower).
For nothing but if/else statements, the leap year one is good. You could also consider:
Test if a number is a multiple of 3, 5 or 7.
Given an age, figure out whether someone's a baby, toddler, child, teenager, adult or old codger.
Calculate grades A-F based on final percentage score.
Given a number on the roulette table, figure out whether it's red/black, high/low and odd/even.
Given a blackjack hand, check if it's okay or bust (this is good since J/Q/K morph into 10). You could also figure out whether to draw another card (if total under 17 for example).
That's just a smattering of possibilities that you could get away with. | 4 | 11 | 0 | What would be a good set of programming exercises that would help Python newbies to learn the use of the "if ... else" construct? I could cook up the following, do you know of any more?
Find the largest/smallest of three numbers.
Given a date (year, month, day), find the next date.
Most of the intended audience have not had much of an exposure to programming before, and I am keen on getting them used to thinking correctly about "if ... else" (and all the rest of it, in due course). | What are good programming questions to exercise the use of "if ... else" in Python? | 1 | 0 | 0 | 14,476 |
3,394,757 | 2010-08-03T08:16:00.000 | 0 | 0 | 1 | 0 | python,if-statement | 3,397,650 | 11 | false | 0 | 0 | I like the "Three men and a monkey on an island" problem:
Three men are stranded on a desert
island with a monkey. They collect
all of the coconuts and put them into
a big pile. Then throughout the night
each man gets up secretly and takes
1/3rd of the remaining pile and hides it. When
he splits the pile into thirds there's
1 remaining which he gives to the
monkey. Then in the morning after
they all wake up they split the pile
into 1/3rds ... with 1 left-over for
the monkey. How many coconuts were in
the pile originally?
The general strategy for solving this is to use a for-loop to check all numbers from 1-10,000 (or some other large number). You need to use if statements to check the remainder. You can later expand this problem to a more general word problem of X-men and Y-monkeys ... this requires a nested for-loop. | 4 | 11 | 0 | What would be a good set of programming exercises that would help Python newbies to learn the use of the "if ... else" construct? I could cook up the following, do you know of any more?
Find the largest/smallest of three numbers.
Given a date (year, month, day), find the next date.
Most of the intended audience have not had much of an exposure to programming before, and I am keen on getting them used to thinking correctly about "if ... else" (and all the rest of it, in due course). | What are good programming questions to exercise the use of "if ... else" in Python? | 0 | 0 | 0 | 14,476 |
3,394,757 | 2010-08-03T08:16:00.000 | 0 | 0 | 1 | 0 | python,if-statement | 32,794,893 | 11 | false | 0 | 0 | At my lecture I asked them to implement is_between_5_8(x) (I admit, there's no ulterior motive with using 5 and 8), and afterward I gave them the exercises to implement abs(x) and closest_to_zero(x, y).
If you've taught them recursion I can give you a few more suggestions :) | 4 | 11 | 0 | What would be a good set of programming exercises that would help Python newbies to learn the use of the "if ... else" construct? I could cook up the following, do you know of any more?
Find the largest/smallest of three numbers.
Given a date (year, month, day), find the next date.
Most of the intended audience have not had much of an exposure to programming before, and I am keen on getting them used to thinking correctly about "if ... else" (and all the rest of it, in due course). | What are good programming questions to exercise the use of "if ... else" in Python? | 0 | 0 | 0 | 14,476 |
3,395,409 | 2010-08-03T09:58:00.000 | 1 | 1 | 0 | 0 | c#,python,apache,mod-wsgi | 3,395,446 | 2 | true | 0 | 0 | Trivially.
Apache serves static content.
Certain URI's will be routed to mod_wsgi to Python.
Python will then execute (via subprocess) a C# program, providing command-line arguments, and reading the standard output response from the C# program.
Python does whatever else is required to serve the web pages.
This presumes your C# application runs at the command line, reads command-line parameters and writes its result to standard output. This is an easy thing to build. It may not be the way it works today, but any program that runs from the command line is trivial to integrate.
Your C# application, BTW, can also be rewritten into Python. It isn't magic. It's just code. Read the code, understand the code, and translate the code. You'll be a lot happier replacing the C# with something simpler. | 1 | 0 | 0 | I have a c# application that defines a membership provider used in a Asp.Net MVC application.
And i have an apache httpd server that does authentication with mod_wsgi.
The objective is to share the membership provider between the two, so that the authentication information be the same.
How can i achieve this behaviour ? | using c# inside an apache python script | 1.2 | 0 | 0 | 145 |
3,396,503 | 2010-08-03T12:38:00.000 | 1 | 0 | 0 | 1 | python,linux,fuse | 7,897,314 | 2 | false | 0 | 0 | Did you set st_size properly in getattr? ls will first try with a buffer size of the returned st_size and double it until the the readlink buffer fits. | 1 | 3 | 0 | I am implementing a filesystem using Python Fuse. A directory contains only symlinks and as such I return S_IFLNK | 0777 on the getattr method.
Now, when I do an ls on the directory, I notice that Linux calls readlink method 6 times in a row for each entry in the directory.
Is it a bug on my side or a normal behavior? | Python Fuse calling 'readlink' 6 times in a row | 0.099668 | 0 | 0 | 510 |
3,397,599 | 2010-08-03T14:38:00.000 | 17 | 0 | 0 | 0 | python,django,amazon-s3,thumbnails | 5,262,932 | 2 | false | 1 | 0 | easy_thumbnails will do S3-based image thumbnailing for you - you just need to set settings.THUMBNAIL_DEFAULT_STORAGE, so that easy_thumbnails knows which storage to use (in your case, you probably want to set it to the same storage you're using for your ImageFields). | 1 | 5 | 0 | I'm making a website where files are uploaded through the admin and this will then store them on Amazon S3. I'm using django-storages and boto for this, and it seems to be working just fine.
Thing is, I'm used to use my easy_thumbnails (the new sorl.thumbnail) on the template side to create thumbnails on the fly. I prefer this approach, rather than the model side, as it allows for easier maintenance if ever I decide to change the thumbnail size at a later date etc.
But I'm realising that easy_thumbnails doesn't seem to like reading the image now it's stored on Amazon S3. Also, I realised, where exactly would it be putting the thumbnails once made anyhow? Obviously, I'd prefer these to be on Amazon S3 as well. But how do I get these two technologies to play nice?
How would I get easy_thumbnails to store the thumb it creates back on Amazon S3? Or am I just looking at this all wrong?!
Thanks! | In Django, how to get django-storages, boto and easy_thumbnail to work nicely? | 1 | 0 | 0 | 1,958 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.