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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
904,928 | 2009-05-25T00:11:00.000 | -2 | 0 | 1 | 0 | python,padding,strftime | 72,106,318 | 21 | false | 0 | 0 | Use simply strftime("%Y/%-m/%-d") in place of strftime("%Y/%m/%d") to remove zero :
strftime("%Y/%-m/%-d") ==> 2022/5/3
strftime("%Y/%-m/%-d") =>2022/05/03 | 5 | 369 | 0 | When using Python strftime, is there a way to remove the first 0 of the date if it's before the 10th, ie. so 01 is 1? Can't find a %thingy for that?
Thanks! | Python strftime - date without leading 0? | -0.019045 | 0 | 0 | 188,421 |
904,928 | 2009-05-25T00:11:00.000 | 2 | 0 | 1 | 0 | python,padding,strftime | 38,662,476 | 21 | false | 0 | 0 | Old question, but %l (lower-case L) worked for me in strftime: this may not work for everyone, though, as it's not listed in the Python documentation I found | 5 | 369 | 0 | When using Python strftime, is there a way to remove the first 0 of the date if it's before the 10th, ie. so 01 is 1? Can't find a %thingy for that?
Thanks! | Python strftime - date without leading 0? | 0.019045 | 0 | 0 | 188,421 |
905,005 | 2009-05-25T01:02:00.000 | 0 | 0 | 1 | 0 | python,ide,intellisense | 14,027,081 | 16 | false | 0 | 0 | IronPython is the way to go. Visual Studio has the best intellisense support and you can utilize that using IronPython | 1 | 70 | 0 | Is there an equivalent to 'intellisense' for Python?
Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along. | Python and Intellisense | 0 | 0 | 0 | 43,902 |
905,221 | 2009-05-25T03:30:00.000 | 5 | 0 | 0 | 1 | python,linux,shell | 905,294 | 4 | true | 0 | 0 | os.system() just calls the system() system call ("man 3 system"). On most *nixes this means you get /bin/sh.
Note that export VAR=val is technically not standard syntax (though bash understands it, and I think ksh does too). It will not work on systems where /bin/sh is actually the Bourne shell. On those systems you need to export and set as separate commands. (This will work with bash too.) | 1 | 9 | 0 | I am using /bin/tcsh as my default shell.
However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.
So my question is how can I know the os.system() run command under which shell? | os.system() execute command under which linux shell? | 1.2 | 0 | 0 | 35,436 |
905,403 | 2009-05-25T05:07:00.000 | 0 | 0 | 0 | 0 | python,download,flv | 905,451 | 2 | false | 1 | 0 | if the embed player makes use of some variable where the flv path is set then you can download it, if not.. I doubt you find something to do it "automaticly" since every site make it's own player and identify the file by id not by path, which makes hard to know where the flv file is. | 1 | 1 | 0 | I'm trying to write a script which can automatically download gameplay videos. The webpages look like dota.sgamer.com/Video/Detail/402 and www.wfbrood.com/movie/spl2009/movie_38214.html, they have flv player embedded in the flash plugin.
Is there any library to help me find out the exact flv urls? or any other ideas to get it?
Many thanks for your replies | Is there any library to find out urls of embedded flvs in a webpage? | 0 | 0 | 1 | 382 |
905,902 | 2009-05-25T08:42:00.000 | 0 | 1 | 0 | 0 | python,hosting | 905,924 | 2 | false | 0 | 0 | Usually python is already installed, but it depends on your hoster. Ask them. | 2 | 0 | 0 | Following on my previous question, if I have some hosting how can I put a python script on their that I can then run from there? Do I need to do something special to run it/install something?
EDIT-Clarification-I would like to be able to upload the script which does stuff on the internet-no data is stored on my computer. I then need to schedule it to run once a day. | Storing Python scripts on a webserver | 0 | 0 | 0 | 243 |
905,902 | 2009-05-25T08:42:00.000 | 1 | 1 | 0 | 0 | python,hosting | 906,016 | 2 | false | 0 | 0 | You have to ensure your hoster system supports Python.
You can ask them about that.
To run the script once it is there, you can act in several ways, depending on what you want to do.
You can have your server side language to invoke it (i.e. from the backend of a web page), or if you have a shell access to the machine you can invoke it manually.
Btw, very often hosting providers give a scheduling tool (i.e. an interface for crontab or at) via the hosting plan administration panel, which you could use to start your script.
First thing, anyway, you have to ask your hoster and check Python availability. | 2 | 0 | 0 | Following on my previous question, if I have some hosting how can I put a python script on their that I can then run from there? Do I need to do something special to run it/install something?
EDIT-Clarification-I would like to be able to upload the script which does stuff on the internet-no data is stored on my computer. I then need to schedule it to run once a day. | Storing Python scripts on a webserver | 0.099668 | 0 | 0 | 243 |
906,509 | 2009-05-25T12:16:00.000 | 2 | 0 | 0 | 1 | python,plugins,gnome,rhythmbox | 1,450,802 | 2 | false | 0 | 0 | You can't import rhythmbox "built-in" modules from a standard python console.
As far as I know they aren't real modules, they are just objects from the rhythmbox process exposed to plugins. So you can access them only if you are running your script from the rhythmbox process. | 2 | 0 | 0 | I'm writing a little script for Ubuntu.
My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) .
I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb).
Any ideas? | show lyrics on ubuntu | 0.197375 | 0 | 0 | 1,143 |
906,509 | 2009-05-25T12:16:00.000 | 0 | 0 | 0 | 1 | python,plugins,gnome,rhythmbox | 4,594,514 | 2 | false | 0 | 0 | in this case i guess you'll have to write the whole plugin yourself and , then listen to dbus for change of songs in rhythmbox , to detect which song is being played . | 2 | 0 | 0 | I'm writing a little script for Ubuntu.
My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) .
I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb).
Any ideas? | show lyrics on ubuntu | 0 | 0 | 0 | 1,143 |
907,579 | 2009-05-25T18:05:00.000 | 0 | 0 | 0 | 1 | python,hosting | 907,605 | 5 | false | 0 | 0 | In addition to the other fine answers here, you should be aware that most FTP clients have a chmod command to allow you to set permissions on files at the server. You may not need this if permissions come across properly, but there's a good chance they do not. | 1 | 4 | 0 | My hosting provider says my python script must be made to be executable(chmod755). What does this mean & how do I do it?
Cheers! | Making a Python script executable chmod755? | 0 | 0 | 0 | 3,729 |
908,285 | 2009-05-25T22:39:00.000 | 3 | 1 | 0 | 0 | python,plugins,signing | 908,846 | 2 | false | 0 | 0 | Is there a way to secure this system?
The answer is "that depends".
The two questions you should ask is "what are people supposed to be able to do" and "what are people able to do (for a given implementation)". If there exists an implementation where the latter is a subset of the former, the system can be secured.
One of my friend is working on a programming competition judge: a program which runs a user-submitted program on some test data and compares its output to a reference output. That's damn hard to secure: you want to run other peoples' code, but you don't want to let them run arbitrary code. Is your scenario somewhat similar to this? Then the answer is "it's difficult".
Do you want users to download untrustworthy code from the web and run it with some assurance that it won't hose their machine? Then look at various web languages. One solution is not offering access to system calls (JavaScript) or offering limited access to certain potentially dangerous calls (Java's SecurityManager). None of them can be done in python as far as I'm aware, but you can always hack the interpreter and disallow the loading of external modules not on some whitelist. This is probably error-prone.
Do you want users to write plugins, and not be able to tinker with what the main body of code in your application does? Consider that users can decompile .pyc files and modify them. Assume that those running your code can always modify it, and consider the gold-farming bots for WoW.
One Linux-only solution, similar to the sandboxed web-ish model, is to use AppArmor, which limits which files your app can access and which system calls it can make. This might be a feasible solution, but I don't know much about it so I can't give you advice other than "investigate".
If all you worry about is evil people modifying code while it's in transit in the intertubes, standard cryptographic solutions exist (SSL). If you want to only load signed plugins (because you want to control what the users do?), signing code sounds like the right solution (but beware of crafty users or evil people who edit the .pyc files and disables the is-it-signed check). | 1 | 2 | 0 | I have an application written in python. I created a plugin system for the application that uses egg files. Egg files contain compiled python files and can be easily decompiled and used to hack the application. Is there a way to secure this system? I'd like to use digital signature for this - sign these egg files and check the signature before loading such egg file. Is there a way to do this programmatically from python? Maybe using winapi? | Secure plugin system for python application | 0.291313 | 0 | 0 | 1,311 |
909,929 | 2009-05-26T10:11:00.000 | 0 | 0 | 0 | 0 | python,forms,post,get | 909,975 | 3 | false | 0 | 0 | Since your sample is in PHP, use $_REQUEST, this holds the contents of both $_GET and $_POST. | 1 | 0 | 0 | I have this-
en.wikipedia.org/w/api.php?action=login&lgname=user&lgpassword=password
But it doesn't work because it is a get request. What would the the post request version of this?
Cheers! | Changing a get request to a post in python? | 0 | 0 | 1 | 276 |
911,089 | 2009-05-26T14:46:00.000 | 3 | 1 | 0 | 0 | python,pyserial | 911,772 | 2 | true | 0 | 0 | For general tips on working with pyserial, look at the search S.Lott suggested in the comment.
Regarding the best strategy to implement your application - it all depends on how your protocols are defined. Do the devices immediately respond to queries? Or do they continually send data that must be monitored? This is important to define, as it certainly affects the way you'll want to handle the communication.
Generally, I've found it simple and stable to have a separate thread reading everything from the serial port and just pumping the data into a Queue. The main application logic then can query this queue whenever it needs to and read the data. | 1 | 2 | 0 | Good afternoon,
I would ask some suggestion about the best way to monitor events over the serial port.
I'm using PySerial to write "commands" over the serial port towards some devices and
I would like to receive feedback about the status of this devices.
Wich is the best way: 1) fullfill a pipe and read into, 2) a new thread delegated to read only, or what?
Can I also ask for a simple code to implement the solution? | python monitoring over serial port | 1.2 | 0 | 0 | 6,847 |
911,905 | 2009-05-26T17:53:00.000 | 1 | 0 | 1 | 0 | python,python-datamodel | 911,953 | 7 | false | 0 | 0 | I don't think you can. __getattribute__ doesn't intercept the method call, it only intercepts the method name lookup. So it should return a function (or callable object), which will then be called with whatever parameters specified at the call site.
In particular, if it returns a function which takes (*args, **kwargs), then in that function you can examine the arguments however you want.
I think. I'm not a Python expert. | 1 | 4 | 0 | It seems as though __getattribute__ has only 2 parameters (self, name).
However, in the actual code, the method I am intercepting actually takes arguments.
Is there anyway to access those arguments?
Thanks,
Charlie | Is there a way to access the formal parameters if you implement __getattribute__ | 0.028564 | 0 | 0 | 2,507 |
912,025 | 2009-05-26T18:25:00.000 | 1 | 1 | 1 | 0 | python,module,package,python-import | 7,338,242 | 6 | false | 0 | 0 | The solution above traversing the filesystem for finding submodules is ok as long as you implement every plugin as a filesystem based module.
A more flexible way would be an explicit plugin list in your main module, and have every plugin (whether a module created by file, dynamically, or even instance of a class) adding itself to that list explicitly. Maybe via a registerPlugin function.
Remember: "explicit is better than implicit" is part of the zen of python. | 1 | 13 | 0 | While it is fairly trivial in Python to import a "child" module into another module and list its attributes, it becomes slightly more difficult when you want to import all child modules.
I'm building a library of tools for an existing 3D application. Each tool has its own menu item and sub menus. I'd like the tool to be responsible for creating its own menus as many of them change based on context and templates. I'd like my base module to be able to find all child modules and check for a create_menu() function and call it if it finds it.
What is the easiest way to discover all child modules? | How to find all child modules in Python? | 0.033321 | 0 | 0 | 6,221 |
913,204 | 2009-05-26T23:02:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 913,212 | 7 | false | 0 | 1 | I would assume it'd be the same as running two versions of 2.x; as long as they're each in their own directory you should be OK. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 0.028564 | 0 | 0 | 1,819 |
913,204 | 2009-05-26T23:02:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 913,222 | 7 | false | 0 | 1 | You certainly can. On Mac Ports, there's a tool called python_select that lets you switch among python versions; if nothing like it exists on Windows (momentary googling didn't reveal one), it could certainly be written. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 0.028564 | 0 | 0 | 1,819 |
913,204 | 2009-05-26T23:02:00.000 | 3 | 0 | 1 | 0 | python,python-3.x | 913,225 | 7 | false | 0 | 1 | Typically python is installed with a name like python2.6, so you can have more than one. There may be a symlink from python to one of the numbered files. Quite workable. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 0.085505 | 0 | 0 | 1,819 |
913,204 | 2009-05-26T23:02:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 913,269 | 7 | false | 0 | 1 | Yes, it is possible.
I maintain 3 python installations (2.5, 2.6, 3.0). The only issue that could be confusing is figuring out which Python version takes precedence in PATH variable (if any) . To execute a script for a specific version, you would go into the python directory for that version
C:\Python25\ , C:\Python26\, C:\Python30\, etc.
Drop the file in there, and run "python.exe file.py" from command-line.
You could even rename each python.exe to python25.exe python26.exe python30.exe and have each directory in PATH so it would be easy to execute any script on any version. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 0.057081 | 0 | 0 | 1,819 |
913,204 | 2009-05-26T23:02:00.000 | 3 | 0 | 1 | 0 | python,python-3.x | 913,223 | 7 | false | 0 | 1 | Erm... yes. I just installed Python 3.0 on this computer to test it. You haven't specified your operating system, but I'm running Ubuntu 9.04 and I can explicitly specify the version of Python I want to run by typing python2.5 myscript.py or python3.0 myscript.py, depending on my needs. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 0.085505 | 0 | 0 | 1,819 |
913,204 | 2009-05-26T23:02:00.000 | 9 | 0 | 1 | 0 | python,python-3.x | 913,216 | 7 | true | 0 | 1 | If you are on Windows, then just install another version of Python using the installer. It would be installed into another directory.
Then if you install other packages using the installer, it would ask you for which python installation to apply. If you use installation from source or easy_install, then just make sure that when you install, you are using the one of the proper version.
If you have many packages installed in your current python-3, then just make a zip backup of your current installation just in case. | 6 | 3 | 0 | How would I do this? The reason being I wanted to try some pygame out, but I have python 3 installed currently and have been learning with that. I'm also interested in trying out wxpython or something like that, but I haven't looked at their compatibilities yet.
EDIT:: im on a windows vista 64-bit | Is it possible to install python 3 and 2.6 on same PC? | 1.2 | 0 | 0 | 1,819 |
915,135 | 2009-05-27T11:03:00.000 | 5 | 1 | 1 | 0 | python | 915,195 | 2 | true | 0 | 0 | Read the Python 3.0 changes. The point of 2.6 is to aim for 3.0.
From 2.4 to 2.6 you gained a lot of things. These are the the most important. I'm making this answer community wiki so other folks can edit it.
Generator functions and the yield statement.
More consistent use of various types like list and dict -- they can be extended directly.
from __future__ import with_statement
from __future__ import print_function
Exceptions are new style classes, and there's more consistent exception handling. String exceptions have been removed. Attempting to use them raises a TypeError | 1 | 4 | 0 | I'm migrating a legacy codebase at work from python 2.4 to python 2.6. This is being done as part of a push to remove the 'legacy' tag and make a maintainable, extensible foundation for active development, so I'm getting a chance to "do things right", including refactoring to use new 2.6 features if that leads to cleaner, more robust code. (I'm already in raptures over the 'with' statement :)). Any good tips for the migration? Best practices, design patterns, etc? I'm mostly a ruby programmer; I've learnt some python 2.4 while working with this code but know nothing about modern python design principles, so feel free to suggest things that you might think are obvious. | Migrating from python 2.4 to python 2.6 | 1.2 | 0 | 0 | 3,565 |
915,726 | 2009-05-27T13:34:00.000 | 2 | 0 | 0 | 0 | python,web-services,scripting,reporting,ms-office | 921,061 | 2 | true | 0 | 0 | I can only agree with Reef on the general concepts he presented:
You will almost certainly prefer the data in a database than in a single large file
You should not worry that the data is not directly manipulated by users because as Reef mentioned, it can only go wrong. And you would be suprised at how ugly it can get
Concerning the usage of MS Office integration tools I disagree with Reef. You can quite easily create an ActiveX Server (in Python if you like) that is accessible from the MS Office suite. As long as you have a solid infrastructure that allows some sort of file share, you could use that shared area to keep your code. I guess the mess Reef was talking about mostly is about keeping users' versions of your extract/import code in sync. If you do not use some sort of shared repository (a simple shared folder) or if your infrastructure fails you often so that the shared folder becomes unavailable you will be in great pain. Note what is also somewhat painful if you do not have the appropriate tools but deal with many users: The ActiveX Server is best registered on each machine.
So.. I just said MS Office integration is very doable. But whether it is the best thing to do is a different matter. I strongly believe you will serve your users better if you build a web-site that handles their data for them. This sort of tool however almost certainly becomes an "ongoing project". Often, even as an "ongoing project", the time saved by your users could still make it worth it. But sometimes, strategically, you want to give your users a poorer experience to control project costs. In that case the ActiveX Server I mentioned could be what you want. | 2 | 2 | 0 | We have lots of data and some charts repesenting one logical item. Charts and data is stored in various files. As a result, most users can easily access and re-use the information in their applications.
However, this not exactly a good way of storing data. Amongst other reasons, charts belong to some data, the charts and data have some meta-information that is not reflected in the file system, there are a lot of files, etc.
Ideally, we want
one big "file" that can store all
information (text, data and charts)
the "file" is human readable,
portable and accessible by
non-technical users
allows typical office applications
like MS Word or MS Excel to extract
text, data and charts easily.
light-weight, easy solution. Quick
and dirty is sufficient. Not many
users.
I am happy to use some scripting language like Python to generate the "file", third-party tools (ideally free as in beer), and everything that you find on a typical Windows-centric office computer.
Some ideas that we currently ponder:
using VB or pywin32 to script MS Word or Excel
creating html and publish it on a RESTful web server
Could you expand on the ideas above? Do you have any other ideas? What should we consider? | Reporting charts and data for MS-Office users | 1.2 | 1 | 0 | 325 |
915,726 | 2009-05-27T13:34:00.000 | 1 | 0 | 0 | 0 | python,web-services,scripting,reporting,ms-office | 920,669 | 2 | false | 0 | 0 | Instead of using one big file, You should use a database. Yes, You can store various types of files like gifs in the database if You like to.
The file would not be human readable or accessible by non-technical users, but this is good.
The database would have a website that Your non-technical users would use to insert, update and get data from. They would be able to display it on the page or export it to csv (or even xls - it's not that hard, I've seen some csv->xls converters). You could look into some open standard document formats, I think it should be quite easy to output data with in it. Do not try to output in "doc" format (but You could try "docx"). You should be able to easily teach the users how to export their data to a CSV and upload it to the site, or they could use the web interface to insert the data if they like to.
If You will allow Your users to mess with the raw data, they will break it (i have tried that, You have no idea how those guys could do that). The only way to prevent it is to make a web form that only allows them to perform certain actions that You exactly know how that they should suppose to perform.
The database + web page solution is the good one. Using VB or pywin32 to script MSOffice will get You in so much trouble I cannot even imagine.
You could use gnuplot or some other graphics library to draw (pretty straightforward to implement, it does all the hard work for You).
I am afraid that the "quick" and dirty solution is tempting, but I only can say one thing: it will not be quick. In a few weeks You will find that hacking around with MSOffice scripting is messy, buggy and unreliable and the non-technical guys will hate it and say that in other companies they used to have a simple web panel that did that. Then You will find that You will not be able to ask about the scripting because everyone uses the web interfaces nowadays, as they are quite easy to implement and maintain.
This is not a small project, it's a medium sized one, You need to remember this while writing it. It will take some time to do it and test it and You will have to add new features as the non-technical guys will start using it. I knew some passionate php teenagers who would be able to write this panel in a week, but as I understand You have some better resources so I hope You will come with a really reliable, modular, extensible solution with good usability and happy users.
Good luck! | 2 | 2 | 0 | We have lots of data and some charts repesenting one logical item. Charts and data is stored in various files. As a result, most users can easily access and re-use the information in their applications.
However, this not exactly a good way of storing data. Amongst other reasons, charts belong to some data, the charts and data have some meta-information that is not reflected in the file system, there are a lot of files, etc.
Ideally, we want
one big "file" that can store all
information (text, data and charts)
the "file" is human readable,
portable and accessible by
non-technical users
allows typical office applications
like MS Word or MS Excel to extract
text, data and charts easily.
light-weight, easy solution. Quick
and dirty is sufficient. Not many
users.
I am happy to use some scripting language like Python to generate the "file", third-party tools (ideally free as in beer), and everything that you find on a typical Windows-centric office computer.
Some ideas that we currently ponder:
using VB or pywin32 to script MS Word or Excel
creating html and publish it on a RESTful web server
Could you expand on the ideas above? Do you have any other ideas? What should we consider? | Reporting charts and data for MS-Office users | 0.099668 | 1 | 0 | 325 |
916,663 | 2009-05-27T16:16:00.000 | 5 | 0 | 0 | 0 | python,3d,direct3d | 1,360,670 | 13 | false | 0 | 1 | The answer to what I think your specific question is, "... in pure Python ..." the answer is NO.
Python is not fast enough to call OpenGL or DirectX efficently enough to re-create World Of Warcraft at an exceptable frame rate.
Like many others have answered, given some high level frame work, it would be possible to use Python has the scripting language but at a minimum you'd need some kind of graphics system written in another language like C++ to handle the graphics. For networking, given that WoW is not an action game, you might be able to get away with pure python but most likely that part as well would need to be some non-python library. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0.076772 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 2 | 0 | 0 | 0 | python,3d,direct3d | 1,656,715 | 13 | false | 0 | 1 | As a technologist I know:
If it can be written in C\C++ it can be written in assembly (though it will take longer).
If it can be written in C\C++ and is not a low-level code - it can be written in any managed environment.
WoW is a high-level program that is written in C\C++
python is a managed environment
There for:
WoW can be written in python and so any other MMORPG in 3D...
The hardest part will be the 3d engine for it is the "heaviest" part of code - you will need to use an outside engine (written in C\C++\Assebly) or to write one and optimize it (not recommended) | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0.03076 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 4 | 0 | 0 | 0 | python,3d,direct3d | 1,656,654 | 13 | false | 0 | 1 | I have been trying my hand at writing 3D games in Python, and given a good rendering framework (my favourite is OGRE) and decent bindings, it is amazing what you can get away with. However, especially with games, you are always trying to squeeze as much as you can out of the hardware. The performance disadvantage of python eventually will make itself felt.
The main problem I ran into using python is its massive call overhead. Calling python functions, even from other python functions is very expensive. In a way, it's the price you pay for the dynamic nature of python. When you use the function call operator "()" on a symbol, it has to work out whether it's a function or a class, look over the method resolution order, handle the keyword arguments, etc etc. All these things are done ahead of time in less dynamic (compiled) languages.
I have seen people trying to overcome this problem by manually inlining function calls. I do not have to tell you that this medicine is worse than the ailment. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0.061461 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 2 | 0 | 0 | 0 | python,3d,direct3d | 930,968 | 13 | false | 0 | 1 | Just because it might give an interesting read, Civilization is partly written using Python.
A google on it returns interesting reading material. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0.03076 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 0 | 0 | 0 | 0 | python,3d,direct3d | 916,693 | 13 | false | 0 | 1 | Because Python is interpreted there would be a performance hit, as opposed to C/C++, but, you would want to use something like PyOpenGL instead of DirectX though, to run on more operating systems.
But, I don't see why you couldn't write such a game in Python. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 6 | 0 | 0 | 0 | python,3d,direct3d | 916,704 | 13 | false | 0 | 1 | Yes, you could write it in assembly, or Java, or Python, or brainfuck. It's just how much time you are willing to put into it. Language performance's aren't a major issue anymore, it's more about which algorithms you use, not what language you use. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 1 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 9 | 0 | 0 | 0 | python,3d,direct3d | 916,701 | 13 | false | 0 | 1 | Technically, anything is possible in any Turing Complete programming language.
Practically though, you will run into trouble making the networking stack out of a high level language, because the server will have to be VERY fast to handle so many players.
The gaming side of things on the client, there should be no problem, because there is nothing too complicated about GUIs or quests or keyboard input and what have you.
The problems will be in whatever is computationally intensive up on the server. Anything that happens in human-time like logging on will probably be just fine, but if somemthing needs to be instantaneous over ten thousand users, you might want to go for an external library done up in C.
Now some Python guru is going to come out of the woodwork and rip my head off because, as I said at the top, technically, anything can be done with enough effort. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 1 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 17 | 0 | 0 | 0 | python,3d,direct3d | 916,686 | 13 | false | 0 | 1 | Yes. How it will perform is another question.
A good development pattern would be to develop it in pure python, and then profile it, and rewrite performance-critical bottlenecks, either in C/C++/Cython or even python itself but with more efficient code. | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 1 | 0 | 0 | 10,718 |
916,663 | 2009-05-27T16:16:00.000 | 0 | 0 | 0 | 0 | python,3d,direct3d | 1,316,198 | 13 | false | 0 | 1 | Python is not interpreted - it is tokenized/'just in time' bytecode 'interpreted' and it doesn't have a VM like Java does. This means, in english, it can be daaaaaamnfast. Not all the time though, it depends on the problem and the libraries, but python is not slow, this is a common misconception even among knowledgable people (and that includes deep java engine folks who have just not gone and tried python). | 9 | 12 | 0 | Would it be possible to write a 3D game as large as World of Warcraft in pure Python?
Assuming the use of DirectX / D3D bindings or OpenGL bindings.
If not, what would be the largest hold-up to doing such a project in Python? I know games tend to fall into the realm of C and C++ but sometimes people do things out of habit!
Any information would help satisfy my curiosity.
Edit:
Would the GIL post a major issue on 3d client performance? And what is the general performance penalty for using say, OpenGL or DirectX bindings vs natively using the libraries? | Would it be possible to write a 3D game as large as World of Warcraft in pure Python? | 0 | 0 | 0 | 10,718 |
916,779 | 2009-05-27T16:39:00.000 | 2 | 0 | 1 | 0 | python,xml,perl,configparser | 916,939 | 6 | false | 0 | 0 | ConfigParser is a fine way of doing it. There are other ways (the json and cPickle modules already mentioned may be useful) that are also good, depending on whether you want to have text files or binary files and if you want code to work simply in older versions of Python or not.
You may want to have a thin abstraction layer on top of your chosen way to make it easier to change your mind. | 2 | 2 | 0 | I want to save a set of key, value pairs (string, int) between runs of a Python program, reload them on subsequent runs and write the changes to be available on the next run.
I don't think of this data as a configuration file, but it would fit the ConfigParser capabilities quite well. I would only need two [sections]. It's only a few hundred pairs and very simple so I don't think it's necessary to do an actual database.
Is it appropriate to use ConfigParser in this way? I've also considered using Perl and XML::Simple. What about that? Is there a way to do this in bash without Python or Perl? | Is something like ConfigParser appropriate for saving state (key, value) between runs? | 0.066568 | 0 | 0 | 2,055 |
916,779 | 2009-05-27T16:39:00.000 | 0 | 0 | 1 | 0 | python,xml,perl,configparser | 916,912 | 6 | false | 0 | 0 | Re doing it in bash: If your strings are valid identifiers, you could use environment variables and env. | 2 | 2 | 0 | I want to save a set of key, value pairs (string, int) between runs of a Python program, reload them on subsequent runs and write the changes to be available on the next run.
I don't think of this data as a configuration file, but it would fit the ConfigParser capabilities quite well. I would only need two [sections]. It's only a few hundred pairs and very simple so I don't think it's necessary to do an actual database.
Is it appropriate to use ConfigParser in this way? I've also considered using Perl and XML::Simple. What about that? Is there a way to do this in bash without Python or Perl? | Is something like ConfigParser appropriate for saving state (key, value) between runs? | 0 | 0 | 0 | 2,055 |
916,962 | 2009-05-27T17:09:00.000 | 8 | 1 | 1 | 0 | php,python,oop,comparison | 917,005 | 6 | false | 0 | 0 | Python's OOP support is very strong; it does allow multiple inheritance, and everything is manipulable as a first-class object (including classes, methods, etc).
Polymorphism is expressed through duck typing. For example, you can iterate over a list, a tuple, a dictionary, a file, a web resource, and more all in the same way.
There are a lot of little pedantic things that are debatably not OO, like getting the length of a sequence with len(list) rather than list.len(), but it's best not to worry about them. | 4 | 17 | 0 | I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable.
If there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware.
Thanks Everyone!
Edit:
How about support for Public and Private? or support of variable types. I think these are important regarding building OOP software. | How does Python OOP compare to PHP OOP? | 1 | 0 | 0 | 3,813 |
916,962 | 2009-05-27T17:09:00.000 | 20 | 1 | 1 | 0 | php,python,oop,comparison | 916,974 | 6 | true | 0 | 0 | I would say that Python's OOP support is much better given the fact that it was introduced into the language in its infancy as opposed to PHP which bolted OOP onto an existing procedural model. | 4 | 17 | 0 | I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable.
If there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware.
Thanks Everyone!
Edit:
How about support for Public and Private? or support of variable types. I think these are important regarding building OOP software. | How does Python OOP compare to PHP OOP? | 1.2 | 0 | 0 | 3,813 |
916,962 | 2009-05-27T17:09:00.000 | 3 | 1 | 1 | 0 | php,python,oop,comparison | 917,052 | 6 | false | 0 | 0 | Also: Python has native operator overloading, unlike PHP (although it does exist an extension). Love it or hate it, it's there. | 4 | 17 | 0 | I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable.
If there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware.
Thanks Everyone!
Edit:
How about support for Public and Private? or support of variable types. I think these are important regarding building OOP software. | How does Python OOP compare to PHP OOP? | 0.099668 | 0 | 0 | 3,813 |
916,962 | 2009-05-27T17:09:00.000 | 1 | 1 | 1 | 0 | php,python,oop,comparison | 917,054 | 6 | false | 0 | 0 | If you are looking for "more pure" OOP, you should be looking at SmallTalk and/or Ruby.
PHP has grown considerably with it's support for OOP, but because of the way it works (reloads everything every time), things can get really slow if OOP best practices are followed. Which is one of the reasons you don't hear about PHP on Rails much. | 4 | 17 | 0 | I'm basically wondering if Python has any OOP shortcomings like PHP does. PHP has been developing their OOP practices for the last few versions. It's getting better in PHP but it's still not perfect. I'm new to Python and I'm just wondering if Python's OOP support is better or just comparable.
If there are some issues in Python OOP which don't follow proper OOP practices I would definitely like to know those. PHP for instance, doesn't allow for multiple inheritance as far as I'm aware.
Thanks Everyone!
Edit:
How about support for Public and Private? or support of variable types. I think these are important regarding building OOP software. | How does Python OOP compare to PHP OOP? | 0.033321 | 0 | 0 | 3,813 |
916,987 | 2009-05-27T17:16:00.000 | 0 | 0 | 0 | 0 | python,windows,linux,user-interface,wxpython | 917,040 | 3 | false | 0 | 1 | EDIT: I just remembered this: Does anybody know why when subclassing wx.App an OnInit() method is required, rather than the more logical __init__()?
I use OnInit() for symmetry: there's also an OnExit() method.
Edit: I may be wrong, but I don't think using OnInit() is required. | 2 | 1 | 0 | The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details.
For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutorials don't work in my computer.
So, do you know what important differences are there, or maybe a good tutorial that is focused on Windows?
EDIT: I just remembered this: Does anybody know why when subclassing wx.App an OnInit() method is required, rather than the more logical __init__()? | WxPython differences between Windows and Linux | 0 | 0 | 0 | 2,618 |
916,987 | 2009-05-27T17:16:00.000 | 0 | 0 | 0 | 0 | python,windows,linux,user-interface,wxpython | 935,519 | 3 | false | 0 | 1 | I find a number of small differences, but don't remember all of them. Here are two:
1) The layout can be slightly different, for example, causing things to not completely fit in the window in one OS when the do in the other. I haven't investigated the reasons for this, but it happens most often when I use positions rather than sizers to arrange things.
2) I have to explicitly call Refresh more in Windows. For example, if you place one panel over another, you won't see it the top panel in Windows until you call Refresh.
I general, I write apps in Linux and run them in Windows, and things work similarly enough so this is a reasonable approach, but it's rare for me when something runs perfectly straight out of the gate after an OS switch. | 2 | 1 | 0 | The tutorials I've found on WxPython all use examples from Linux, but there seem to be differences in some details.
For example, in Windows a Panel behind the widgets is mandatory to show the background properly. Additionally, some examples that look fine in the tutorials don't work in my computer.
So, do you know what important differences are there, or maybe a good tutorial that is focused on Windows?
EDIT: I just remembered this: Does anybody know why when subclassing wx.App an OnInit() method is required, rather than the more logical __init__()? | WxPython differences between Windows and Linux | 0 | 0 | 0 | 2,618 |
917,876 | 2009-05-27T20:31:00.000 | 1 | 0 | 1 | 1 | python,macos,osx-leopard,reinstall | 917,897 | 3 | true | 0 | 0 | /Library/Python contains your python site-packages, which is the local software you've installed using commands like python setup.py install. The pieces here are third-party packages, not items installed by Apple - your actual Python installation is still safe in /System/Library/etc...
In other words, the default OS leaves these directories mostly blank... nothing in there is critical (just a readme and a path file).
In this case, you'll have to :
Recreate the directory structure:
Re-install your third-party libraries.
The directory structure on a default OS X install is:
/Library/Python/2.3/site-packages
/Library/Python/2.5/site-packages | 2 | 0 | 0 | I accidentally removed /Library/Python on OS X Leopard. How can I reinstall that? | Reinstall /Library/Python on OS X Leopard | 1.2 | 0 | 0 | 2,889 |
917,876 | 2009-05-27T20:31:00.000 | 1 | 0 | 1 | 1 | python,macos,osx-leopard,reinstall | 917,890 | 3 | false | 0 | 0 | If you'd like, I'll create a tarball from a pristine installation. I'm using MacOSX 10.5.7, and only 12K. | 2 | 0 | 0 | I accidentally removed /Library/Python on OS X Leopard. How can I reinstall that? | Reinstall /Library/Python on OS X Leopard | 0.066568 | 0 | 0 | 2,889 |
918,154 | 2009-05-27T21:43:00.000 | 4 | 0 | 0 | 0 | python,relative-path,path | 20,437,590 | 21 | false | 0 | 0 | Hi first of all you should understand functions os.path.abspath(path) and os.path.relpath(path)
In short os.path.abspath(path) makes a relative path to absolute path. And if the path provided is itself a absolute path then the function returns the same path.
similarly os.path.relpath(path) makes a absolute path to relative path. And if the path provided is itself a relative path then the function returns the same path.
Below example can let you understand the above concept properly:
suppose i have a file input_file_list.txt which contains list of input files to be processed by my python script.
D:\conc\input1.dic
D:\conc\input2.dic
D:\Copyioconc\input_file_list.txt
If you see above folder structure, input_file_list.txt is present in Copyofconc folder and the files to be processed by the python script are present in conc folder
But the content of the file input_file_list.txt is as shown below:
..\conc\input1.dic
..\conc\input2.dic
And my python script is present in D: drive.
And the relative path provided in the input_file_list.txt file are relative to the path of input_file_list.txt file.
So when python script shall executed the current working directory (use os.getcwd() to get the path)
As my relative path is relative to input_file_list.txt, that is "D:\Copyofconc", i have to change the current working directory to "D:\Copyofconc".
So i have to use os.chdir('D:\Copyofconc'), so the current working directory shall be "D:\Copyofconc".
Now to get the files input1.dic and input2.dic, i will read the lines "..\conc\input1.dic" then shall use the command
input1_path= os.path.abspath('..\conc\input1.dic') (to change relative path to absolute path. Here as current working directory is "D:\Copyofconc", the file ".\conc\input1.dic" shall be accessed relative to "D:\Copyofconc")
so input1_path shall be "D:\conc\input1.dic" | 2 | 365 | 0 | I'm building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don't, however, have the absolute path to the directory where the templates are stored. I do have a relative path from the script but when I call the script it treats that as a path relative to the current working directory. Is there a way to specify that this relative url is from the location of the script instead? | Relative paths in Python | 0.038077 | 0 | 0 | 684,930 |
918,154 | 2009-05-27T21:43:00.000 | 0 | 0 | 0 | 0 | python,relative-path,path | 69,999,696 | 21 | false | 0 | 0 | Say the current archive named "Helper" and the upper directory named "Workshop", and the template files are in \Workshop\Templates, then the relative path in Python is "..\Templates". | 2 | 365 | 0 | I'm building a simple helper script for work that will copy a couple of template files in our code base to the current directory. I don't, however, have the absolute path to the directory where the templates are stored. I do have a relative path from the script but when I call the script it treats that as a path relative to the current working directory. Is there a way to specify that this relative url is from the location of the script instead? | Relative paths in Python | 0 | 0 | 0 | 684,930 |
919,857 | 2009-05-28T08:52:00.000 | 0 | 0 | 1 | 0 | python,hardware | 11,354,777 | 9 | false | 0 | 0 | I'm not too sure anyone has mentioned the BASIC stamp. Again - it is very limited, but its SUPER simple to start working with. There are some other processors up there they make too, but as an introductory - I think its a great device.
Arduino too is a good one, and you can probably get more bang for you buck with that device.
As mentioned above, I got my start on PIC processors - which are not the easiest thing to work with initially (or really ever... haha - its debateable), but I got a great understanding of how things work in the world of micro controller / hardware interaction.
Best of luck & if you have any questions, feel free to ask away! | 2 | 14 | 0 | I am starting to get a bit bored of programming little toys that I have been making recently, and I would love to starting programming and interacting with hardware.
The only problem is that I am mostly a python guy who hasn't really learned or used any other language. Can I still interact with hardware with python?
Also, what hardware can I interact with? I don't really have stuff lying around that I can use, so I would have to buy a kit or something. What are some cheap options for this? | Programming with hardware in python | 0 | 0 | 0 | 36,107 |
919,857 | 2009-05-28T08:52:00.000 | 1 | 0 | 1 | 0 | python,hardware | 5,507,016 | 9 | false | 0 | 0 | The SNAP wireless nodes at www.synapse-wireless.com run a subset of Python called SNAPpy. You can use the peek() and poke() built-ins in the SNAPpy language to interact directly with hardware inside the chip (PWM for example). SNAPpy also has built-ins for I2C, SPI, and serial, so you can control external hardware. It also has built-ins for lower level I/O too, like readPin() writePin() and readAdc(). Something like an EK2500 kit might be good to start with. See also the online user forum at forums.synapse-wireless.com | 2 | 14 | 0 | I am starting to get a bit bored of programming little toys that I have been making recently, and I would love to starting programming and interacting with hardware.
The only problem is that I am mostly a python guy who hasn't really learned or used any other language. Can I still interact with hardware with python?
Also, what hardware can I interact with? I don't really have stuff lying around that I can use, so I would have to buy a kit or something. What are some cheap options for this? | Programming with hardware in python | 0.022219 | 0 | 0 | 36,107 |
920,278 | 2009-05-28T10:57:00.000 | 1 | 0 | 0 | 0 | python,cookies | 920,727 | 2 | false | 0 | 0 | Usually, we do the following.
Use a framework.
Establish a session. Ideally, ask for a username of some kind. If you don't want to ask for names or anything, you can try to the browser's IP address as the key for the session (this can turn into a nightmare, but you can try it.)
Using the session identification (username or IP address), save the searches in a database on your server.
When the person logs in again, retrieve their query information from your local database.
Moral of the story. Don't trust the cookie to have anything it but session identification. And even then, it will get hijacked either on purpose or accidentally.
Intentional hijacking is the way one person poses as another.
Accident hijacking occurs when multiple people share the same IP address (because they share the same computer). | 1 | 0 | 0 | Hey i have a webpage for searching a database. i would like to be able to implement cookies using python to store what a user searches for and provide them with a recently searched field when they return. is there a way to implement this using the python Cookie library?? | Using cookies with python to store searches | 0.099668 | 0 | 1 | 1,329 |
920,645 | 2009-05-28T12:44:00.000 | 80 | 0 | 1 | 0 | python,loops | 920,692 | 10 | true | 0 | 0 | Yes, there is a huge difference between while and for.
The for statement iterates through a collection or iterable object or generator function.
The while statement simply loops until a condition is False.
It isn't preference. It's a question of what your data structures are.
Often, we represent the values we want to process as a range (an actual list), or xrange (which generates the values) (Edit: In Python 3, range is now a generator and behaves like the old xrange function. xrange has been removed from Python 3). This gives us a data structure tailor-made for the for statement.
Generally, however, we have a ready-made collection: a set, tuple, list, map or even a string is already an iterable collection, so we simply use a for loop.
In a few cases, we might want some functional-programming processing done for us, in which case we can apply that transformation as part of iteration. The sorted and enumerate functions apply a transformation on an iterable that fits naturally with the for statement.
If you don't have a tidy data structure to iterate through, or you don't have a generator function that drives your processing, you must use while. | 4 | 41 | 0 | I am finding problems in when I should use a while loop or a for loop in Python. It looks like people prefer using a for loop (less code lines?). Is there any specific situation which I should use one or the other? Is it a matter of personal preference? The codes I have read so far made me think there are big differences between them. | When to use "while" or "for" in Python | 1.2 | 0 | 0 | 133,264 |
920,645 | 2009-05-28T12:44:00.000 | -1 | 0 | 1 | 0 | python,loops | 68,777,278 | 10 | false | 0 | 0 | For me if your problem demands multiple pointers to be used to keep
track of some boundary I would always prefer While loop.
In other cases it's simply for loop. | 4 | 41 | 0 | I am finding problems in when I should use a while loop or a for loop in Python. It looks like people prefer using a for loop (less code lines?). Is there any specific situation which I should use one or the other? Is it a matter of personal preference? The codes I have read so far made me think there are big differences between them. | When to use "while" or "for" in Python | -0.019997 | 0 | 0 | 133,264 |
920,645 | 2009-05-28T12:44:00.000 | 0 | 0 | 1 | 0 | python,loops | 67,131,941 | 10 | false | 0 | 0 | If your data is dirty and it won't work with a for loop, you need to clean your data. | 4 | 41 | 0 | I am finding problems in when I should use a while loop or a for loop in Python. It looks like people prefer using a for loop (less code lines?). Is there any specific situation which I should use one or the other? Is it a matter of personal preference? The codes I have read so far made me think there are big differences between them. | When to use "while" or "for" in Python | 0 | 0 | 0 | 133,264 |
920,645 | 2009-05-28T12:44:00.000 | 0 | 0 | 1 | 0 | python,loops | 63,624,000 | 10 | false | 0 | 0 | while loop is better for normal loops
for loop is much better than while loop while working with strings, like lists, strings etc. | 4 | 41 | 0 | I am finding problems in when I should use a while loop or a for loop in Python. It looks like people prefer using a for loop (less code lines?). Is there any specific situation which I should use one or the other? Is it a matter of personal preference? The codes I have read so far made me think there are big differences between them. | When to use "while" or "for" in Python | 0 | 0 | 0 | 133,264 |
920,938 | 2009-05-28T13:49:00.000 | 0 | 0 | 1 | 0 | python,formatting,ms-word,ms-office,openoffice.org | 921,046 | 7 | false | 0 | 0 | I think OpenOffice has some Python bindings - you should be able to write OO macros in Python.
But I would use HTML instead - Word and OO.org are rather good at editing it and you can write it from Python easily (although Word saves a lot of mess which could complicate parsing it by your Python app). | 2 | 6 | 0 | I am working on a project (in Python) that needs formatted, editable output. Since the end-user isn't going to be technically proficient, the output needs to be in a word processor editable format. The formatting is complex (bullet points, paragraphs, bold face, etc).
Is there a way to generate such a report using Python? I feel like there should be a way to do this using Microsoft Word/OpenOffice templates and Python, but I can't find anything advanced enough to get good formatting. Any suggestions? | Formatted output in OpenOffice/Microsoft Word with Python | 0 | 0 | 0 | 5,281 |
920,938 | 2009-05-28T13:49:00.000 | 3 | 0 | 1 | 0 | python,formatting,ms-word,ms-office,openoffice.org | 922,117 | 7 | false | 0 | 0 | A little known, and slightly evil fact: If you create an HTML file, and stick a .doc extension on it, Word will open it as a Word document, and most users will be none the wiser.
Except maybe a very technical person will say, my this is a small Word file! :) | 2 | 6 | 0 | I am working on a project (in Python) that needs formatted, editable output. Since the end-user isn't going to be technically proficient, the output needs to be in a word processor editable format. The formatting is complex (bullet points, paragraphs, bold face, etc).
Is there a way to generate such a report using Python? I feel like there should be a way to do this using Microsoft Word/OpenOffice templates and Python, but I can't find anything advanced enough to get good formatting. Any suggestions? | Formatted output in OpenOffice/Microsoft Word with Python | 0.085505 | 0 | 0 | 5,281 |
921,268 | 2009-05-28T14:55:00.000 | 2 | 0 | 0 | 0 | .net,ssis,ironpython | 1,233,648 | 1 | false | 0 | 0 | Set up a column which holds a CHECKSUM() of each row. Do a left outer join between the two tables . If you have any nulls for the right side, you have problems. | 1 | 0 | 0 | A table has been ETLed to another table. My task is to verify the data between two tables programmatically.
One of the difficulties I m facing rite now is:
how to use the expression that I can get from, let s say, derived column task and verify with the source and destination.
or in other words, how can I use the expression to work in the code.
Any ideas....highly appreciated
Sagar | How to compare data of two tables transformed in SSIS package | 0.379949 | 1 | 0 | 1,102 |
921,532 | 2009-05-28T15:35:00.000 | 4 | 1 | 1 | 0 | python,cookies | 921,544 | 4 | false | 0 | 0 | Look at the Cookie: headers in the HTTP response you get, parse their contents with module Cookie in the standard library. | 1 | 20 | 0 | How do I read back all of the cookies in Python without knowing their names? | Retrieving all Cookies in Python | 0.197375 | 0 | 0 | 43,214 |
922,319 | 2009-05-28T17:55:00.000 | 0 | 0 | 0 | 0 | python,zope | 1,022,056 | 3 | false | 0 | 0 | If you really move everything you could probably just move the Data.fs instead. But otherwise the import/export above is a good way. | 1 | 5 | 0 | We have two zope servers running our company's internal site. One is the live site and one is the dev site. I'm working on writing a python script that moves everything from the dev server to the live server. Right now the process involves a bunch of steps that are done in the zope management interface. I need to make all that automatic so that running one script handles it all. One thing I need to do is export one folder from the live server so that I can reimport it back into the live site after the update. How can I do this from a python script?
We're using Zope 2.8 and python 2.3.4 | Exporting a zope folder with python | 0 | 0 | 0 | 1,260 |
922,351 | 2009-05-28T18:01:00.000 | 0 | 1 | 0 | 0 | python,pylons,paster | 980,897 | 2 | false | 0 | 0 | If you set the environment variable PYTHONSTARTUP to the name of a file, it will execute that file on opening the interactive prompt.
I don't know anything about paster shell, but I assume it works similarly.
Alternatively you could look into iPython, which has much more powerful features (particularly when installed with the readline library). For example %run allows you to run a script in the current namespace, or you can use history completion.
Edit:
Okay. Having looked into it a bit more, I'm fairly certain that paster shell just does a set of useful imports, and could be easily replicated with a short script and ipython and then %run myscript.py
Edit:
Having looked at the source, it would be very hard to do (I was wrong about the default imports. It parses your config file as well), however if you have Pylons and iPython both installed, then paster shell should use iPython automagically. Double check that both are installed properly, and double check that paster shell isn't using iPython already (it might be looking like normal python prompt). | 1 | 5 | 0 | Is it possible to run "paster shell blah.ini" (or a variant thereof) and have it automatically load certain libraries?
I hate having to always type "from foo.bar import mystuff" as the first command in every paster shell, and would like the computer to do it for me. | Is it possible to launch a Paster shell with some modules pre-imported? | 0 | 0 | 0 | 1,107 |
922,681 | 2009-05-28T19:14:00.000 | 0 | 1 | 0 | 0 | c#,.net,scripting,ironpython | 922,701 | 2 | false | 0 | 1 | If you right click your project and go to Properties theres a Publish tab, that allows you to specify prerequisite installs for your application.
Presumably you can supply a path to the IronPython install executable here. | 2 | 2 | 0 | I'm am trying to roll out a test application to test the feasibility of righting a Click Once Smart Client app that also uses a rules engine customizable by embedding IronPython.
So far all users but me get this error (below) when invoking the script engine.
Do I need to do something special to force deployment of the IronPython and Scripting assemblies? I thought that would be automatic because they were referenced in my project.
Is this just not feasible in .NET 2.0?
Thoughts?
************** Exception Text **************
System.MissingMethodException: Method not found: 'Void System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], Boolean)'.
at Microsoft.Scripting.Utils.Helpers.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)
at Microsoft.Linq.Expressions.Compiler.Snippets.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CreateDynamicLambdaCompiler(CompilerScope scope, String methodName, Type returnType, IList`1 paramTypes, IList`1 paramNames, Boolean closure, Boolean emitDebugSymbols, Boolean forceDynamic)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda(LambdaExpression lambda, Type delegateType, Boolean emitDebugSymbols, Boolean forceDynamic, MethodInfo& method)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda[T](LambdaExpression lambda, Boolean emitDebugSymbols)
at Microsoft.Linq.Expressions.LambdaExpression.Compile[T](Boolean emitDebugSymbols)
at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression code, Scope scope)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at UAP.UI.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) | IronPython, Click Once, .NET 2.0 Error - thoughts? | 0 | 0 | 0 | 1,241 |
922,681 | 2009-05-28T19:14:00.000 | 4 | 1 | 0 | 0 | c#,.net,scripting,ironpython | 923,395 | 2 | false | 0 | 1 | IronPython requiers .NET 2.0SP1 or later to run. This exception is happening due to an overload that was added in SP1. | 2 | 2 | 0 | I'm am trying to roll out a test application to test the feasibility of righting a Click Once Smart Client app that also uses a rules engine customizable by embedding IronPython.
So far all users but me get this error (below) when invoking the script engine.
Do I need to do something special to force deployment of the IronPython and Scripting assemblies? I thought that would be automatic because they were referenced in my project.
Is this just not feasible in .NET 2.0?
Thoughts?
************** Exception Text **************
System.MissingMethodException: Method not found: 'Void System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], Boolean)'.
at Microsoft.Scripting.Utils.Helpers.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)
at Microsoft.Linq.Expressions.Compiler.Snippets.CreateDynamicMethod(String name, Type returnType, Type[] parameterTypes)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CreateDynamicLambdaCompiler(CompilerScope scope, String methodName, Type returnType, IList`1 paramTypes, IList`1 paramNames, Boolean closure, Boolean emitDebugSymbols, Boolean forceDynamic)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda(LambdaExpression lambda, Type delegateType, Boolean emitDebugSymbols, Boolean forceDynamic, MethodInfo& method)
at Microsoft.Linq.Expressions.Compiler.LambdaCompiler.CompileLambda[T](LambdaExpression lambda, Boolean emitDebugSymbols)
at Microsoft.Linq.Expressions.LambdaExpression.Compile[T](Boolean emitDebugSymbols)
at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression code, Scope scope)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at UAP.UI.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) | IronPython, Click Once, .NET 2.0 Error - thoughts? | 0.379949 | 0 | 0 | 1,241 |
922,771 | 2009-05-28T19:34:00.000 | 2 | 1 | 0 | 0 | python,templates,mako | 923,030 | 7 | false | 1 | 0 | What I ended up doing was naming my Mako Templates with .html suffix and thus getting the usual HTML syntax highlighting etc. that I am used to. Alternatively I could have associated .mako suffix with the HTML handler. While this does not address Mako specifically, it was enough for me, since I find most of the template is plain HTML anyway. | 3 | 12 | 0 | Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?
I know that there is a .mako syntax highlighter for the default text editor in Ubuntu. | Syntax Highlight for Mako in Eclipse or TextMate? | 0.057081 | 0 | 0 | 5,178 |
922,771 | 2009-05-28T19:34:00.000 | 0 | 1 | 0 | 0 | python,templates,mako | 30,838,894 | 7 | false | 1 | 0 | Windows (menu) > Preference > General > Editor > File Associations
Add *.mako in File Types (upper box) and add Html editor in Associated editor (lower box)
Windows (menu) > Preference > General > Editor > Content Types
Under Text find HTML and add *.mako in File associations. | 3 | 12 | 0 | Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?
I know that there is a .mako syntax highlighter for the default text editor in Ubuntu. | Syntax Highlight for Mako in Eclipse or TextMate? | 0 | 0 | 0 | 5,178 |
922,771 | 2009-05-28T19:34:00.000 | 1 | 1 | 0 | 0 | python,templates,mako | 8,544,623 | 7 | false | 1 | 0 | You can go to:
Preferences->General->Editors->File Associations.
Click to add a new file type and type *.mak and click OK.
In File types click on *.mak and under Associated editors add HTML editor(default), Text Editor, Text Editor(studio) and Web Browser.
This colors the text, works OK for me :)
P.S. Be sure to have the Aptana plugin installed. | 3 | 12 | 0 | Does anyone know of a syntax highlight for Mako templates for Eclipse or for TextMate?
I know that there is a .mako syntax highlighter for the default text editor in Ubuntu. | Syntax Highlight for Mako in Eclipse or TextMate? | 0.028564 | 0 | 0 | 5,178 |
922,774 | 2009-05-28T19:35:00.000 | 3 | 0 | 1 | 0 | python,typechecking,python-2.5 | 922,799 | 9 | false | 0 | 0 | Check the type with isinstance(arg, basestring) | 1 | 66 | 0 | I've a method that I want to be able to accept either a single string (a path, but not necessarily one that exists on the machine running the code) or a list/tuple of strings.
Given that strings act as lists of characters, how can I tell which kind the method has received?
I'd like to be able to accept either standard or unicode strings for a single entry, and either lists or tuples for multiple, so isinstance doesn't seem to be the answer unless I'm missing a clever trick with it (like taking advantage of common ancestor classes?).
Python version is 2.5 | Check if input is a list/tuple of strings or a single string | 0.066568 | 0 | 0 | 83,961 |
922,788 | 2009-05-28T19:37:00.000 | 7 | 0 | 1 | 1 | python,kernel | 922,814 | 4 | true | 0 | 0 | It's going to be very difficult to do the process monitoring part in Python, since the python interpreter doesn't run in the kernel.
I suspect there are two easy approaches to this:
use the /proc filesystem if you have one (you don't mention your OS)
Use dtrace if you have dtrace (again, without the OS, who knows.)
Okay, following up after the edit.
First, there's no way you're going to be able to write code that runs in the kernel, in python, and is portable between Linux and Windows. Or at least if you were to, it would be a hack that would live in glory forever.
That said, though, if your purpose is to process Python, there are a lot of Python tools available to get information from the Python interpreter at run time.
If instead your desire is to get process information from other processes in general, you're going to need to examine the options available to you in the various OS APIs. Linux has a /proc filesystem; that's a useful start. I suspect Windows has similar APIs, but I don't know them.
If you have to write kernel code, you'll almost certainly need to write it in C or C++. | 1 | 2 | 0 | I would like seek some guidance in writing a "process profiler" which runs in kernel mode. I am asking for a kernel mode profiler is because I run loads of applications and I do not want my profiler to be swapped out.
When I said "process profiler" I mean to something that would monitor resource usage by the process. including usage of threads and their statistics.
And I wish to write this in python. Point me to some modules or helpful resource.
Please provide me guidance/suggestion for doing it.
Thanks,
Edit::: Would like to add that currently my interest isto write only for linux. however after i built it i will have to support windows. | Writing a kernel mode profiler for processes in python | 1.2 | 0 | 0 | 2,476 |
923,586 | 2009-05-28T22:48:00.000 | 0 | 0 | 1 | 1 | python,windows,testing,environment-variables | 2,318,893 | 3 | false | 0 | 0 | You cannot use environment variables in this way. As you have discovered it is not persistent after the setting application completes | 1 | 0 | 0 | I'm developing a script that runs a program with other scripts over and over for testing purposes.
How it currently works is I have one Python script which I launch. That script calls the program and loads the other scripts. It kills the program after 60 seconds to launch the program again with the next script.
For some scripts, 60 seconds is too long, so I was wondering if I am able to set a FLAG variable (not in the main script), such that when the script finishes, it sets FLAG, so the main script and read FLAG and kill the process?
Thanks for the help, my writing may be confusing, so please let me know if you cannot fully understand. | Python Environment Variables in Windows? | 0 | 0 | 0 | 1,306 |
923,680 | 2009-05-28T23:21:00.000 | 1 | 1 | 0 | 0 | php,python,linux | 924,481 | 3 | false | 0 | 0 | A permission problem is most likely the case.
If apache is running as apache, then it will not have access to write to a file unless
The file is owned by apache
The file is in the group apache and group writable
The file is world writable
This is a "sticky" problem on a multi-user machine, as different people have access to Apache.
Try chmod 666 output.txt on the file and then re-run your test.
Considerations:
Have the python script write the output to a database
Use PHP's popen functionality to open the process and communicate over pipes
Re-write using PHP's regular expressions
Write the output file to /tmp and then read the results using PHP as soon as the python script is done.
etc... | 2 | 1 | 0 | Scenario:
I have a php page in which I call a python script.
Python script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file.
Python script when run through php, doesn't do either.
Elaboration:
I use a simple system command in PHP to run the python script as:
/var/www/html/1.php:
system('/usr/python/bin/python3 ../cgi-bin/tabular.py 1');
/var/www/cgi-bin/tabular.py
--This python file basically parses a data file, uses python's regular expression to search for specific headings and outputs the headings to the stdout, as well as write it to a file.
This python script has a few routines in it which get executed, so I put print statements to debug. I noticed only a few initial print statements' output in the PHP page, all the ones from the function that actually does something are not seen.
Also, as part of my test, I thought well the py script is in a different folder so let me change it to the /var/www/html folder, no go.
I hope I captured the problem statement with sufficient detail and someone is able to reproduce this issue at their end. If I make any progress on this one myself, I'll annotate this question. Thanks everyone.
Gaurav | When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation | 0.066568 | 0 | 0 | 1,882 |
923,680 | 2009-05-28T23:21:00.000 | 0 | 1 | 0 | 0 | php,python,linux | 923,761 | 3 | false | 0 | 0 | Check that the user the python script is running is has write permissions in CWD. Also, try shell_exec() or passthru() to call the script, rather than system(). | 2 | 1 | 0 | Scenario:
I have a php page in which I call a python script.
Python script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file.
Python script when run through php, doesn't do either.
Elaboration:
I use a simple system command in PHP to run the python script as:
/var/www/html/1.php:
system('/usr/python/bin/python3 ../cgi-bin/tabular.py 1');
/var/www/cgi-bin/tabular.py
--This python file basically parses a data file, uses python's regular expression to search for specific headings and outputs the headings to the stdout, as well as write it to a file.
This python script has a few routines in it which get executed, so I put print statements to debug. I noticed only a few initial print statements' output in the PHP page, all the ones from the function that actually does something are not seen.
Also, as part of my test, I thought well the py script is in a different folder so let me change it to the /var/www/html folder, no go.
I hope I captured the problem statement with sufficient detail and someone is able to reproduce this issue at their end. If I make any progress on this one myself, I'll annotate this question. Thanks everyone.
Gaurav | When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation | 0 | 0 | 0 | 1,882 |
923,691 | 2009-05-28T23:25:00.000 | 0 | 1 | 0 | 1 | python,testing,scripting | 923,720 | 8 | false | 0 | 0 | Most commercial products install an "Agent" on the remote machines.
In the linux world, you have numerous such agents. rexec and rlogin and rsh all jump to mind.
These are all clients that communication with daemons running on the remote hosts.
If you don't want to use these agents, you can read about them and reinvent these wheels in pure Python. Essentially, the client (rexec for example) communicates with the server (rexecd) to send work requests. | 4 | 2 | 0 | I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines).
I've considered a couple of ideas, namely:
- Starting a process and moving it to the background via a trailing ampersand (&)
- Using screen in some fashion
- Using python threads
What else should I be considering? In your experience what have you found to be the best way to accomplish a task like this? | How to start a process on a remote server, disconnect, then later collect output? | 0 | 0 | 0 | 2,588 |
923,691 | 2009-05-28T23:25:00.000 | 0 | 1 | 0 | 1 | python,testing,scripting | 923,719 | 8 | false | 0 | 0 | As @Gandalf mentions, you'll need nohup in addition to the backgrounding &, or the process will be SIGKILLed when the login session terminates. If you redirect your output to a log file, you'll be able to look at it later easily (and not have to install screen on all your machines). | 4 | 2 | 0 | I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines).
I've considered a couple of ideas, namely:
- Starting a process and moving it to the background via a trailing ampersand (&)
- Using screen in some fashion
- Using python threads
What else should I be considering? In your experience what have you found to be the best way to accomplish a task like this? | How to start a process on a remote server, disconnect, then later collect output? | 0 | 0 | 0 | 2,588 |
923,691 | 2009-05-28T23:25:00.000 | 3 | 1 | 0 | 1 | python,testing,scripting | 923,703 | 8 | false | 0 | 0 | nohup for starters (at least on *nix boxes) - and redirect the output to some log file where you can come back and monitor it of course. | 4 | 2 | 0 | I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines).
I've considered a couple of ideas, namely:
- Starting a process and moving it to the background via a trailing ampersand (&)
- Using screen in some fashion
- Using python threads
What else should I be considering? In your experience what have you found to be the best way to accomplish a task like this? | How to start a process on a remote server, disconnect, then later collect output? | 0.07486 | 0 | 0 | 2,588 |
923,691 | 2009-05-28T23:25:00.000 | 0 | 1 | 0 | 1 | python,testing,scripting | 20,889,031 | 8 | false | 0 | 0 | If you are using python to run the automation... I would attempt to automate everything using paramiko. It's a versatile ssh library for python. Instead of going back to the output, you could collect multiple lines of output live and then disconnect when you no longer need the process and let ssh do the killing for you. | 4 | 2 | 0 | I am writing automation code in python to test the behavior of a network application. As such, my code needs to be able to start a process/script (say, tcpdump or a python script) on a server in the network, disconnect, run other processes and then later return and shutdown/evaluate the process started earlier. My network is a mix of windows and linux machines and all of the machines have sshd and python running (via Cygwin for the windows machines).
I've considered a couple of ideas, namely:
- Starting a process and moving it to the background via a trailing ampersand (&)
- Using screen in some fashion
- Using python threads
What else should I be considering? In your experience what have you found to be the best way to accomplish a task like this? | How to start a process on a remote server, disconnect, then later collect output? | 0 | 0 | 0 | 2,588 |
923,701 | 2009-05-28T23:28:00.000 | 5 | 0 | 0 | 0 | python,qt4,pyqt | 923,757 | 2 | false | 0 | 1 | Widgets inside the GNOME panel are called applets, and to my knowledge it's not possible to write them with anything but Gtk, since you have to use the respective GNOME library libpanel-applet (in either C, C++ or Python).
System tray icons are different, because they only allow icons to be displayed inside the notification area, since Windows only supports icons there.
The panel mechanism on Windows (Vista, XP does only have the notification area) is quite different, I would assume. Unless somebody already wrote a library that abstracts the differences of the GNOME panel and the Vista side bar, you would have to do that yourself. | 1 | 4 | 0 | I want to code up a panel that will be used both in Linux and Windows. Ideally it will be written in Python using PyQT.
What I've found so far is the QSystemTrayIcon widget, and while that is quite useful, that's not quite what I'm looking for. That widget lets you attach a menu to the left and right clicks of an icon on the system tray and then you can have a dialog open in certain situations.
I'm looking for something that will let me write up something like the tools that Gnome lets you add to the taskbar (they call them panels). Such as a weather feed, or processor usage, right on the taskbar. And also not in the system tray area.
I'm writing more of a tool than something reflects a status.
I know that I could write this natively in both OSes using GTK and its ilk, but anyway to write in PyQT or WxWidget so I don't have to deal with dependancy issues? | Python taskbar applet | 0.462117 | 0 | 0 | 1,572 |
925,616 | 2009-05-29T11:42:00.000 | 0 | 0 | 0 | 0 | django,stackless,python-stackless | 925,645 | 2 | false | 1 | 0 | I think the solution would be to point eclipse at your 2.5 stackless installation unless you have a very good reason to use 2.6 over 2.5?
...or recompile for 2.6 and add it to your 2.6 installation. | 2 | 1 | 0 | I am trying to run a DJango Command Extension which uses stackless.
I have installed Stackless Python (compiled with python 2.5) so whenever I type python2.5 at the console it fires up indicating that the version is
Python 2.5.2 Stackless 3.1b3 060516 (python-2.52:72942, May 26 2009, 23:07:34)
[GCC 4.3.3] on linux2
But in my eclipse I have configured my django application to run with python2.6. Specifically in the PyDev settings. So obviously when I mention import stackless it says that there is no such package.
The problem is even if I add the '/usr/local/lib/python2.5/site-packages' directory it does not import stackless.
What is the solution to this issue ? | Stackless installation and configuration with DJango | 0 | 0 | 0 | 1,142 |
925,616 | 2009-05-29T11:42:00.000 | 0 | 0 | 0 | 0 | django,stackless,python-stackless | 4,507,213 | 2 | false | 1 | 0 | Choose Window->preferencess in eclipse menu
pydev->interpeter-Python
choose tab forsed biltins
press new, type "stackless" | 2 | 1 | 0 | I am trying to run a DJango Command Extension which uses stackless.
I have installed Stackless Python (compiled with python 2.5) so whenever I type python2.5 at the console it fires up indicating that the version is
Python 2.5.2 Stackless 3.1b3 060516 (python-2.52:72942, May 26 2009, 23:07:34)
[GCC 4.3.3] on linux2
But in my eclipse I have configured my django application to run with python2.6. Specifically in the PyDev settings. So obviously when I mention import stackless it says that there is no such package.
The problem is even if I add the '/usr/local/lib/python2.5/site-packages' directory it does not import stackless.
What is the solution to this issue ? | Stackless installation and configuration with DJango | 0 | 0 | 0 | 1,142 |
925,716 | 2009-05-29T12:22:00.000 | 1 | 0 | 0 | 0 | python,file,ftp,networking,nfs | 926,044 | 2 | false | 0 | 0 | Have a look at KDE IOSlaves. They can manage all the protocol you describe, plus a few others (samba, ssh, ...).
You can instantiates IOSlaves through PyKDE or if that dependency is too big, you can probably manage the ioslave from python with the subprocess module. | 1 | 3 | 0 | I know there is ftplib for ftp, shutil for local files, what about NFS? I know urllib2 can get files via HTTP/HTTPS/FTP/FTPS, but it can't put files.
If there is a uniform library that automatically detects the protocol (FTP/NFS/LOCAL) with URI and deals with file transfer (get/put) transparently, it's even better, does it exist? | Is there a uniform python library to transfer files using different protocols | 0.099668 | 0 | 1 | 1,426 |
925,832 | 2009-05-29T12:58:00.000 | -2 | 0 | 1 | 0 | python,eclipse,debugging,breakpoints,pydev | 926,190 | 5 | false | 0 | 0 | If you are already running in debug mode you can set an additional breakpoint if the program execution is currently paused (e.g. because you are already at a breakpoint). I just tried it out now with the latest Pydev - it works just fine.
If you are running normally (i.e. not in debug mode) all breakpoints will be ignored. No changes to breakpoints will alter the way a non-debug run works. | 1 | 13 | 0 | Hey I was wondering... I am using the pydev with eclipse and I'm really enjoying the powerful debugging features, but I was wondering:
Is it possible to set a breakpoint in eclipse and jump into the interactive python interpreter during execution?
I think that would be pretty handy ;)
edit: I want to emphasize that my goal is not to jump into a debugger. pydev/eclipse have a great debugger, and I can just look at the traceback and set break points.
What I want is to execute a script and jump into an interactive python interpreter during execution so I can do things like...
poke around
check the values of things
manipulate variables
figure out some code before I add it to the app
I know you can do this all with a debugger, but I can do it faster in the interactive interpreter because I can try something, see that it didn't work, and try something else without having get the app back to the point of executing that code again. | Jump into a Python Interactive Session mid-program? | -0.07983 | 0 | 0 | 3,161 |
925,965 | 2009-05-29T13:29:00.000 | 2 | 1 | 0 | 1 | python,fedora,easy-install | 926,006 | 3 | false | 0 | 0 | I suggest you create a virtualenv (or several) for installing packages into. | 2 | 0 | 0 | Fedora Core 9 includes Python 2.5.1. I can use YUM to get latest and greatest releases.
To get ready for 2.6 official testing, I wanted to start with 2.5.4. It appears that there's no Fedora 9 YUM package, because 2.5.4 isn't an official part of FC9.
I downloaded 2.5.4, did ./configure; make; make install and wound up with two Pythons. The official 2.5.1 (in /usr/bin) and the new 2.5.4. (in /usr/local/bin).
None of my technology stack is installed in /usr/local/lib/python2.5.
It appears that I have several choices for going forward. Anyone have any preferences?
Copy /usr/lib/python2.5/* to /usr/local/lib/python2.5 to replicate my environment. This should work, unless some part of the Python libraries have /usr/bin/python wired in during installation. This is sure simple, but is there a down side?
Reinstall everything by running easy_install. Except, easy_install is (currently) hard-wired to /usr/bin/python. So, I'd have to fix easy_install first, then reinstall everything.
This takes some time, but it gives me a clean, new latest-and-greatest environment. But is there a down-side? [And why does easy_install hard-wire itself?]
Relink /usr/bin/python to be /usr/local/bin/python. I'd still have to copy or reinstall the library, so I don't think this does me any good. [It would make easy_install work; but so would editing /usr/bin/easy_install.]
Has anyone copied their library? Is it that simple?
Or should I fix easy_install and simply step through the installation guide and build a new, clean, latest-and-greatest?
Edit
Or, should I
Skip trying to resolve the 2.5.1 and 2.5.4 issues and just jump straight to 2.6? | Fedora Python Upgrade broke easy_install | 0.132549 | 0 | 0 | 1,989 |
925,965 | 2009-05-29T13:29:00.000 | 2 | 1 | 0 | 1 | python,fedora,easy-install | 926,636 | 3 | false | 0 | 0 | I've had similar experiences and issues when installing Python 2.5 on an older release of ubuntu that supplied 2.4 out of the box.
I first tried to patch easy_install, but this led to problems with anything that wanted to use the os-supplied version of python. I was often fiddling with the tool chain to fix different errors that might crop up with every install. Installing any python software via apt, or installing any software from apt that had a python easy_install script as part of the install, was often amusing. I'm sure I could probably have been more vigilant in patching easy_install, but I gave up.
Instead, I copied the library, and everything worked. As you say, there may be issues depending on what you have installed, but I didn't run into issues. Double-checking Python's site.py module, I did see that it operates entirely on relative paths, building absolute paths dynamically; this gave me some confidence to try the "copy everything" approach. I double-checked any .pth files, then went for it. | 2 | 0 | 0 | Fedora Core 9 includes Python 2.5.1. I can use YUM to get latest and greatest releases.
To get ready for 2.6 official testing, I wanted to start with 2.5.4. It appears that there's no Fedora 9 YUM package, because 2.5.4 isn't an official part of FC9.
I downloaded 2.5.4, did ./configure; make; make install and wound up with two Pythons. The official 2.5.1 (in /usr/bin) and the new 2.5.4. (in /usr/local/bin).
None of my technology stack is installed in /usr/local/lib/python2.5.
It appears that I have several choices for going forward. Anyone have any preferences?
Copy /usr/lib/python2.5/* to /usr/local/lib/python2.5 to replicate my environment. This should work, unless some part of the Python libraries have /usr/bin/python wired in during installation. This is sure simple, but is there a down side?
Reinstall everything by running easy_install. Except, easy_install is (currently) hard-wired to /usr/bin/python. So, I'd have to fix easy_install first, then reinstall everything.
This takes some time, but it gives me a clean, new latest-and-greatest environment. But is there a down-side? [And why does easy_install hard-wire itself?]
Relink /usr/bin/python to be /usr/local/bin/python. I'd still have to copy or reinstall the library, so I don't think this does me any good. [It would make easy_install work; but so would editing /usr/bin/easy_install.]
Has anyone copied their library? Is it that simple?
Or should I fix easy_install and simply step through the installation guide and build a new, clean, latest-and-greatest?
Edit
Or, should I
Skip trying to resolve the 2.5.1 and 2.5.4 issues and just jump straight to 2.6? | Fedora Python Upgrade broke easy_install | 0.132549 | 0 | 0 | 1,989 |
926,579 | 2009-05-29T15:23:00.000 | 1 | 0 | 0 | 0 | python,django,apache,mod-python | 928,519 | 1 | false | 1 | 0 | As a workaround, and assuming you are free to install new Apache modules on the server, you might try one of
mod_scgi
mod_fastcgi
mod_wsgi
instead. I use SCGI to connect an nginx frontend webserver to my Django apps, which highlights a major benefit (decoupling from the webserver). All of these packages are available in Debian, probably on RHELx as well. | 1 | 0 | 0 | I am hosting a Django app on Apache using mod_python. Occasionally, I get some cryptic mod_python errors, usually of the ImportError variety, although not usually referring to the same module. The thing is, these seem to come up for a single forked subprocess, while the others operate fine, even when I force behavior that requires using the module that the problem process has errored on. Once the process encounters the error, it will always just serve the same traceback every time Apache chooses it to handle a request. (This is also a hassle, since my users don't necessarily report the error on the first occurrence, and once the process encounters the error.)
I know more about configuring Django than configuring Apache, but that won't get me anywhere since the request never reaches Django for processing. Ideally, I should solve the root problem, and that might involve my code, project, or machine configuration, but until then, I need help diagnosing and mitigating the problem.
Is there any way to configure the Apache logs to include a subprocess id?
Is there any way to force a subprocess to respawn if it has hit an error?
Are there any known issues relating to this that I should know about? | Configure Apache to recover from mod_python errors | 0.197375 | 0 | 0 | 281 |
926,814 | 2009-05-29T16:07:00.000 | 2 | 0 | 1 | 0 | python,memcached | 927,081 | 2 | true | 0 | 0 | From a quick view into the source code: No it does not. It uses server = hash_key % len(servers) and round-robin if offline/full servers are encountered. | 1 | 1 | 0 | I'm using the python-memcache library, and I'm wondering if anyone knows if consistent hashing is used by that client as of 1.44. | Does python-memcache use consistent hashing? | 1.2 | 0 | 0 | 1,100 |
927,866 | 2009-05-29T20:04:00.000 | 0 | 1 | 0 | 1 | python,linux,directory,owner | 927,888 | 6 | false | 0 | 0 | Use the os.stat function. | 2 | 25 | 0 | How can I get the owner and group IDs of a directory using Python under Linux? | How to get the owner and group of a folder with Python on a Linux machine? | 0 | 0 | 0 | 26,467 |
927,866 | 2009-05-29T20:04:00.000 | 0 | 1 | 0 | 1 | python,linux,directory,owner | 71,426,599 | 6 | false | 0 | 0 | If you are using Linux, it is much easier.
Install tree with the command yum install tree. Then execute the command 'tree -a -u -g' | 2 | 25 | 0 | How can I get the owner and group IDs of a directory using Python under Linux? | How to get the owner and group of a folder with Python on a Linux machine? | 0 | 0 | 0 | 26,467 |
929,029 | 2009-05-30T04:52:00.000 | 0 | 0 | 0 | 0 | python,django,many-to-many | 929,073 | 8 | false | 1 | 0 | You can achieve this looking for all the fields in the parent that are an instance of django.db.models.fields.related.RelatedManager. From your example it seems that the child classes you are talking about are not subclasses. Right? | 2 | 84 | 0 | In Django, when you have a parent class and multiple child classes that inherit from it you would normally access a child through parentclass.childclass1_set or parentclass.childclass2_set, but what if I don't know the name of the specific child class I want?
Is there a way to get the related objects in the parent->child direction without knowing the child class name? | How do I access the child classes of an object in django without knowing the name of the child class? | 0 | 0 | 0 | 34,203 |
929,029 | 2009-05-30T04:52:00.000 | 24 | 0 | 0 | 0 | python,django,many-to-many | 929,128 | 8 | false | 1 | 0 | In Python, given a ("new-style") class X, you can get its (direct) subclasses with X.__subclasses__(), which returns a list of class objects. (If you want "further descendants", you'll also have to call __subclasses__ on each of the direct subclasses, etc etc -- if you need help on how to do that effectively in Python, just ask!).
Once you have somehow identified a child class of interest (maybe all of them, if you want instances of all child subclasses, etc), getattr(parentclass,'%s_set' % childclass.__name__) should help (if the child class's name is 'foo', this is just like accessing parentclass.foo_set -- no more, no less). Again, if you need clarification or examples, please ask! | 2 | 84 | 0 | In Django, when you have a parent class and multiple child classes that inherit from it you would normally access a child through parentclass.childclass1_set or parentclass.childclass2_set, but what if I don't know the name of the specific child class I want?
Is there a way to get the related objects in the parent->child direction without knowing the child class name? | How do I access the child classes of an object in django without knowing the name of the child class? | 1 | 0 | 0 | 34,203 |
929,141 | 2009-05-30T06:13:00.000 | 1 | 0 | 1 | 0 | .net,.net-2.0,ironpython | 951,508 | 3 | true | 1 | 0 | i have found the way....
.NET 2.0 and .Net 3.0 do not have SP1.
So either version of .Net with SP1 will make Ironpython work...yippee | 3 | 0 | 0 | I installed ironpython 2.0 in the windows xp professional box and it requires .Net framework 2.0 service pack 2 or later. The windows box has it. But still the console disappears. There is issue in either of them.
Need help? | Ironpython console disappears instantly | 1.2 | 0 | 0 | 218 |
929,141 | 2009-05-30T06:13:00.000 | 1 | 0 | 1 | 0 | .net,.net-2.0,ironpython | 930,888 | 3 | false | 1 | 0 | The same result
Iropython requires .NET 2.0 sp1 or later
There is no error infact...
I suppose Ironpython is not finding the .Net libraries where it is supposed to be.
If the control panel\Add remove programs shows the .Net framework, does this mean they are installed. I am asking this question coz in forums no body has talked about checking the control panel thing; however, they either talk about checking Registry or %systemroot%\Microsoft .net\Framework and check for Mscorlib.dll in the respective version folder.
Well, I have found the .dll file for .net 2.0 and .net 1.1 but not for .net 3.0
If .net 3.0 is not installed, then the reason for failure of ironpython is sp1 for .net 2.0 is not installed.
Also, i checked the registry information at
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\policy\v2.0
and found that .NEt 2.0, the orignal version is installed
however, I found .net 3.0 in .NETFramework folder, but not in policy folder. And in that folder, there is no such folder like v3.0 where the value is set such and such. | 3 | 0 | 0 | I installed ironpython 2.0 in the windows xp professional box and it requires .Net framework 2.0 service pack 2 or later. The windows box has it. But still the console disappears. There is issue in either of them.
Need help? | Ironpython console disappears instantly | 0.066568 | 0 | 0 | 218 |
929,141 | 2009-05-30T06:13:00.000 | 0 | 0 | 1 | 0 | .net,.net-2.0,ironpython | 929,197 | 3 | false | 1 | 0 | What happens if you open a command prompt and run ipy from there?
Run (From the command prompt) ipy -X:ExceptionDetail
This will hopefully give more info.
Also have a look in the Windows Event Log (Application) for any errors related to IPY.
Update If you have no error recorded, try running another .Net program to see if it is a general problem. Uninstalling the Framework and reinstalling the Framework would be the next step to try.
Cheers,
Davy | 3 | 0 | 0 | I installed ironpython 2.0 in the windows xp professional box and it requires .Net framework 2.0 service pack 2 or later. The windows box has it. But still the console disappears. There is issue in either of them.
Need help? | Ironpython console disappears instantly | 0 | 0 | 0 | 218 |
929,887 | 2009-05-30T15:05:00.000 | 2 | 0 | 1 | 0 | python,file | 930,010 | 10 | false | 0 | 0 | I'd like too add to the other solutions that some of them (those who look for \n) will not work with files with OS 9-style line endings (\r only), and that they may contain an extra blank line at the end because lots of text editors append it for some curious reasons, so you might or might not want to add a check for it. | 1 | 2 | 0 | I have 2 simple questions about python:
1.How to get number of lines of a file in python?
2.How to locate the position in a file object to the
last line easily? | Two simple questions about python | 0.039979 | 0 | 0 | 436 |
929,988 | 2009-05-30T15:49:00.000 | 1 | 1 | 0 | 0 | java,python,function,lambda | 41,144,957 | 7 | false | 1 | 0 | With the release of Java 8, lambda-expression is now available.
And the lambda function in java is actually "more powerful" than the python ones.
In Python, lambda-expression may only have a single expression for its body, and no return statement is permitted. In Java, you can do something like this: (int a, int b) -> { return a * b; }; and other optional things as well.
Java 8 also introduces another interface called the Function Interface. You might want to check that out as well. | 1 | 23 | 0 | Can someone please tell me if there is an equivalent for Python's lambda functions in Java? | Equivalent for Python's lambda functions in Java? | 0.028564 | 0 | 0 | 12,221 |
930,397 | 2009-05-30T19:28:00.000 | 6 | 0 | 1 | 0 | python,list,indexing | 32,998,601 | 22 | false | 0 | 0 | Ok, but what about common in almost every language way items[len(items) - 1]? This is IMO the easiest way to get last element, because it does not require anything pythonic knowledge. | 4 | 2,574 | 0 | How do I get the last element of a list? | How do I get the last element of a list? | 1 | 0 | 0 | 2,809,696 |
930,397 | 2009-05-30T19:28:00.000 | 8 | 0 | 1 | 0 | python,list,indexing | 39,908,383 | 22 | false | 0 | 0 | list[-1] will retrieve the last element of the list without changing the list.
list.pop() will retrieve the last element of the list, but it will mutate/change the original list. Usually, mutating the original list is not recommended.
Alternatively, if, for some reason, you're looking for something less pythonic, you could use list[len(list)-1], assuming the list is not empty. | 4 | 2,574 | 0 | How do I get the last element of a list? | How do I get the last element of a list? | 1 | 0 | 0 | 2,809,696 |
930,397 | 2009-05-30T19:28:00.000 | 0 | 0 | 1 | 0 | python,list,indexing | 68,104,450 | 22 | false | 0 | 0 | Couldn't find any answer mentioning this. So adding.
You could try some_list[~0] also.
That's the tilde symbol | 4 | 2,574 | 0 | How do I get the last element of a list? | How do I get the last element of a list? | 0 | 0 | 0 | 2,809,696 |
930,397 | 2009-05-30T19:28:00.000 | 1 | 0 | 1 | 0 | python,list,indexing | 65,459,111 | 22 | false | 0 | 0 | If you do my_list[-1] this returns the last element of the list. Negative sequence indexes represent positions from the end of the array. Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second-last item, etc. | 4 | 2,574 | 0 | How do I get the last element of a list? | How do I get the last element of a list? | 0.009091 | 0 | 0 | 2,809,696 |
930,857 | 2009-05-30T23:28:00.000 | 0 | 0 | 1 | 0 | python | 72,213,695 | 3 | false | 0 | 0 | Not sure if this will help but I had a similar problem. My problem was the main accessor file was not in the root folder. I had it inside another folder. The reference worked as soon and I moved it to the root folder. | 1 | 2 | 0 | In a simple program I made, I wanted to get a list from another project and access the elements from it. Since I'm new to python, I don't really have any idea what to do. In my project, I checked the box for the project name I wanted to reference and... I don't know what to do. A few google searched did me no good, so I'm hoping someone here can tell/link me how to set this up. | Referencing another project | 0 | 0 | 0 | 400 |
931,092 | 2009-05-31T02:10:00.000 | 0 | 0 | 1 | 0 | python,string | 71,039,840 | 26 | false | 0 | 0 | my_str = "hello
Fast Option: my_str[::-1]
Slow Option: "".join(reversed(my_str)) | 2 | 1,553 | 0 | There is no built in reverse function for Python's str object. What is the best way of implementing this method?
If supplying a very concise answer, please elaborate on its efficiency. For example, whether the str object is converted to a different object, etc. | Reverse a string in Python | 0 | 0 | 0 | 1,488,644 |
931,092 | 2009-05-31T02:10:00.000 | 298 | 0 | 1 | 0 | python,string | 931,099 | 26 | false | 0 | 0 | @Paolo's s[::-1] is fastest; a slower approach (maybe more readable, but that's debatable) is ''.join(reversed(s)). | 2 | 1,553 | 0 | There is no built in reverse function for Python's str object. What is the best way of implementing this method?
If supplying a very concise answer, please elaborate on its efficiency. For example, whether the str object is converted to a different object, etc. | Reverse a string in Python | 1 | 0 | 0 | 1,488,644 |
931,423 | 2009-05-31T05:58:00.000 | -1 | 1 | 1 | 0 | php,python,html-entities,htmlspecialchars | 931,442 | 8 | false | 1 | 0 | If you are using django 1.0 then your template variables will already be encoded and ready for display. You also use the safe operator {{ var|safe }} if you don't want it globally turned on. | 1 | 20 | 0 | Is there a similar or equivalent function in Python to the PHP function htmlspecialchars()? The closest thing I've found so far is htmlentitydefs.entitydefs(). | Is there a Python equivalent to the PHP function htmlspecialchars()? | -0.024995 | 0 | 0 | 12,591 |
931,580 | 2009-05-31T07:44:00.000 | 0 | 0 | 0 | 0 | winforms,ironpython | 931,629 | 2 | false | 1 | 1 | As an interface designer, it's important to use an many standard windows controls as possible. The more your app looks like the microsoft ones users are used to, they will become more comfortable with it quicker.
A good example is how out of place iTunes and Safari look in windows. My tip is to just keep it with the windows look. | 1 | 0 | 0 | I want to change the look of my Ironpython windows forms, Is it possible to change the style of the form and for example make it more like a Mac?
thank you | Different styles for Windows forms in Ironpython | 0 | 0 | 0 | 706 |
931,995 | 2009-05-31T12:48:00.000 | 18 | 0 | 1 | 0 | python,math,floating-point | 932,007 | 9 | false | 0 | 0 | Always assume that floating point operations will have some error in them and check for equality taking that error into account (either a percentage value like 0.00001% or a fixed value like 0.00000000001). This inaccuracy is a given since not all decimal numbers can be represented in binary with a fixed number of bits precision.
Your particular case is not one of them if Python uses IEEE754 since 31 should be easily representable with even single precision. It's possible however that it loses precision in one of the many steps it takes to calculate log2231, simply because it doesn't have code to detect special cases like a direct power of two. | 2 | 15 | 0 | I work daily with Python 2.4 at my company. I used the versatile logarithm function 'log' from the standard math library, and when I entered log(2**31, 2) it returned 31.000000000000004, which struck me as a bit odd.
I did the same thing with other powers of 2, and it worked perfectly. I ran 'log10(2**31) / log10(2)' and I got a round 31.0
I tried running the same original function in Python 3.0.1, assuming that it was fixed in a more advanced version.
Why does this happen? Is it possible that there are some inaccuracies in mathematical functions in Python? | Inaccurate Logarithm in Python | 1 | 0 | 0 | 10,703 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.