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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,320,761 | 2010-12-01T02:47:00.000 | 13 | 0 | 0 | 1 | python,cx-freeze,winreg | 48,344,053 | 4 | false | 0 | 0 | I know this is an old question, but this was the first search result when Googling for ModuleNotFoundError: No module named '_winreg', and perhaps may be helpful for someone.
I got the same error when trying to use a virtual environment folder, which has been created using different (already deleted) python binaries. The solution was recreate the virtual environment:
Delete the virtual environment folder
Run python -m venv <name_of_virtual_environment> | 1 | 22 | 0 | Where can I download _winreg for python3 if I can at all. I have my 'windir' on E:\Windows. I do not know if cx_Freeze did not notice that. I am using cx_Freeze to create an msi installer. | importError: no module named _winreg python3 | 1 | 0 | 0 | 38,800 |
4,321,160 | 2010-12-01T04:18:00.000 | 0 | 0 | 1 | 0 | python,dictionary,key | 4,321,256 | 7 | false | 0 | 0 | The answer is no.
If you want to know if there are solutions that are fast to type, then, sure, check out the other replies. But none of them will run quickly on large dictionaries, which I believe was the spirit of your question.
If this is really something you need to do often, you should modify the points in your code that add and remove keys from your dictionary so that they also maintain a heap of keys, sorted by their word count. | 1 | 2 | 0 | Is there a way to quickly query a dictionary object in order to find the key (all keys are of string type) with the most words?
I.e., if the item with the largest key had five words {'this is the largest key': 3}, how could I quickly query the dict and have the int '5' returned?
Best,
Georgina | Python - Find longest (most words) key in dictionary | 0 | 0 | 0 | 3,861 |
4,321,173 | 2010-12-01T04:21:00.000 | 3 | 0 | 0 | 0 | python,django,google-app-engine,caching,internationalization | 4,321,229 | 2 | false | 1 | 0 | I don't know how this works with django, but looking at it from a general web-development perspective, you could:
use a query parameter to determine the language (e.g. /foo/bar/page.py?lang=en)
Add the language code to the url path (e.g. /foo/bar/en/page.py), and optionally use mod_rewrite so that that part of the path gets passed to your script as a query parameter. | 1 | 1 | 0 | I have developed an AppEngine/Python/Django application that currently works in Spanish, and I am in the process of internationalizing with multi-language support. It is basically a dating website, in which people can browse other profiles and send messages. Viewing a profile in different languages will result in some of the text (menus etc) being displayed in whichever language is selected, but user-generated content (ie. user profile or message) will be displayed in the original language in which it was written.
My question is: is it necessary (or a good idea) to use unique URLs for the same page being displayed in different languages or is it OK to overload the same URL for a given page being displayed in different languages. In particular, I am worried that if I use the same URL for multiple languages, then some pages might be cached (either by Google, or by some other proxy that I might not be aware of), which could result in an incorrect language being displayed to a user.
Does anyone know if this is a legitimate concern, or if I am worrying about something that will not happen? | Multi-language website - unique URLs required for different languages (to prevent caching)? | 0.291313 | 0 | 0 | 552 |
4,321,836 | 2010-12-01T06:35:00.000 | 1 | 0 | 1 | 0 | python | 4,321,874 | 4 | false | 0 | 0 | Function declarations in Python do not involve any types, because variables in Python don't have types - values have types.
You don't declare the function separately, you just write it. The first line of a function looks like def name_of_function(arguments, go, here):. In your case, there are two things that are being passed: {'a': '123', 'b': 'Zab'}, and 'acb'. So you need to specify two arguments, and give them names.
{'a': '123', 'b': 'Zab'} is a single "thing" - 'a': '123' is meaningless on its own. The whole thing is a value, not a variable. The type of the value is dict. The value represents a logical mapping: that is, the value encodes the concept of "'a' corresponds to '123', and 'b' corresponds to 'Zab'".
I assume, given the name replace_all, that the intent is to look at every character in 'acb', and replace it with the corresponding value (if any) from the dict.
You get "the corresponding value" from a dict by using the "key" as an index. Thus, if you have the value {'a': '123', 'b': 'Zab'} bound to the variable my_dict, then evaluating my_dict['a'] gives the result '123', since that is the value associated with the 'a' key in that dict. If the key isn't actually in the dict (for example my_dict['c']), this will raise KeyError. You can either handle the exception, or else use one of the "safe" access functions, such as the .get method of the dict. Refer to the documentation for more info. | 2 | 1 | 0 | Homework question:
Write a function which is called like: replace_all({'a':'123', 'b':'Zab'}, 'acb')
What does the function declaration look like?
What kind of variable is 'a':'123' and {}? | Meaning of curly brackets and colons? | 0.049958 | 0 | 0 | 6,589 |
4,321,836 | 2010-12-01T06:35:00.000 | 0 | 0 | 1 | 0 | python | 4,324,190 | 4 | false | 0 | 0 | The declaration of such a function is " def replace_all(Dictionary, String): ". with the '{}' is designating a dictionary data structure of python in which 'a', 'b' are keys and they have there own corresponding values." 'a':'123' " is called an item of the dictionary (if you are considering " 'a':'123' " in context of this same dictionary otherwise it is a string) and they can be retrieved as a tuple.
For further details just look into the python manual for dictionary and dict.items() | 2 | 1 | 0 | Homework question:
Write a function which is called like: replace_all({'a':'123', 'b':'Zab'}, 'acb')
What does the function declaration look like?
What kind of variable is 'a':'123' and {}? | Meaning of curly brackets and colons? | 0 | 0 | 0 | 6,589 |
4,321,993 | 2010-12-01T07:04:00.000 | 1 | 0 | 1 | 0 | python,windows,processor | 4,322,005 | 6 | false | 0 | 0 | Assuming your task is parallelizable, then yes, threading is certainly a solution. In particular, if you have a lot of data items to process but they can all be handled independently then it should be relatively straightforward to parallelize.
Using multiple processes instead of multiple threads might be another solution - you haven't told us enough about the problem to say, really. | 2 | 5 | 0 | I am running a single-threaded python program that performs massive data processing on my windows box. My machine has 8 processors. When I monitor the CPU usage in performance tab under Windows Task Manager, it shows that I am using only a very small fraction of the processing power available to me. Only one processor is being used to the fullest and all the rest are almost idle. What should I do to ensure that all my processors are used? Is multithreading a solution? | How to program to have all processors on your machine used? | 0.033321 | 0 | 0 | 2,647 |
4,321,993 | 2010-12-01T07:04:00.000 | 2 | 0 | 1 | 0 | python,windows,processor | 4,322,009 | 6 | false | 0 | 0 | Multithreading is required for a single process, but it is not necessarily a solution; processor affinity can restrict it to a subset of available cores even if you have more than enough threads to use all. | 2 | 5 | 0 | I am running a single-threaded python program that performs massive data processing on my windows box. My machine has 8 processors. When I monitor the CPU usage in performance tab under Windows Task Manager, it shows that I am using only a very small fraction of the processing power available to me. Only one processor is being used to the fullest and all the rest are almost idle. What should I do to ensure that all my processors are used? Is multithreading a solution? | How to program to have all processors on your machine used? | 0.066568 | 0 | 0 | 2,647 |
4,322,250 | 2010-12-01T07:52:00.000 | 0 | 0 | 1 | 1 | python,linux,macos,executable | 4,322,272 | 3 | false | 0 | 0 | Dont know if available for OS X but take a look at cx_freeze | 2 | 1 | 0 | is it possible to create python executable targeted for linux, from mac os x?
PyInstaller seems to be at an early stage, and I don't know much else.
Thanks | python executable | 0 | 0 | 0 | 4,099 |
4,322,250 | 2010-12-01T07:52:00.000 | 5 | 0 | 1 | 1 | python,linux,macos,executable | 4,322,264 | 3 | false | 0 | 0 | Do you really need a standalone executable? For most Linux distributions, the easier and more common way to distribute Python software is to just distribute the source.
Every major Linux distribution already has Python installed, and some have it installed by default. | 2 | 1 | 0 | is it possible to create python executable targeted for linux, from mac os x?
PyInstaller seems to be at an early stage, and I don't know much else.
Thanks | python executable | 0.321513 | 0 | 0 | 4,099 |
4,322,559 | 2010-12-01T08:45:00.000 | 29 | 0 | 0 | 0 | python,r,hadoop,bigdata | 4,323,638 | 2 | true | 0 | 0 | Using the Python Disco project for example.
Good. Play with that.
Using the RHIPE package and finding toy datasets and problem areas.
Fine. Play with that, too.
Don't sweat finding "big" datasets. Even small datasets present very interesting problems. Indeed, any dataset is a starting-off point.
I once built a small star-schema to analyze the $60M budget of an organization. The source data was in spreadsheets, and essentially incomprehensible. So I unloaded it into a star schema and wrote several analytical programs in Python to create simplified reports of the relevant numbers.
Finding the right information to allow me to decide if I need to move to NoSQL from RDBMS type databases
This is easy.
First, get a book on data warehousing (Ralph Kimball's The Data Warehouse Toolkit) for example.
Second, study the "Star Schema" carefully -- particularly all the variants and special cases that Kimball explains (in depth)
Third, realize the following: SQL is for Updates and Transactions.
When doing "analytical" processing (big or small) there's almost no update of any kind. SQL (and related normalization) don't really matter much any more.
Kimball's point (and others, too) is that most of your data warehouse is not in SQL, it's in simple Flat Files. A data mart (for ad-hoc, slice-and-dice analysis) may be in a relational database to permit easy, flexible processing with SQL.
So the "decision" is trivial. If it's transactional ("OLTP") it must be in a Relational or OO DB. If it's analytical ("OLAP") it doesn't require SQL except for slice-and-dice analytics; and even then the DB is loaded from the official files as needed. | 1 | 41 | 1 | I've been a long time user of R and have recently started working with Python. Using conventional RDBMS systems for data warehousing, and R/Python for number-crunching, I feel the need now to get my hands dirty with Big Data Analysis.
I'd like to know how to get started with Big Data crunching.
- How to start simple with Map/Reduce and the use of Hadoop
How can I leverage my skills in R and Python to get started with Big Data analysis. Using the Python Disco project for example.
Using the RHIPE package and finding toy datasets and problem areas.
Finding the right information to allow me to decide if I need to move to NoSQL from RDBMS type databases
All in all, I'd like to know how to start small and gradually build up my skills and know-how in Big Data Analysis.
Thank you for your suggestions and recommendations.
I apologize for the generic nature of this query, but I'm looking to gain more perspective regarding this topic.
Harsh | How to get started with Big Data Analysis | 1.2 | 0 | 0 | 18,227 |
4,324,407 | 2010-12-01T12:36:00.000 | 17 | 0 | 0 | 0 | python,sqlalchemy,nosql,redis | 4,331,070 | 2 | false | 0 | 0 | While it is possible to set up an ORM that puts data in redis, it isn't a particularly good idea. ORMs are designed to expose standard SQL features. Many things that are standard in SQL such as querying on arbitrary columns are not available in redis unless you do a lot of extra work. At the same time redis has features such as set manipulation that do not exist in standard SQL so will not be used by the ORM.
Your best option is probably to write your code to interact directly with redis rather than trying to use an inappropriate abstraction - Generally you will find that the code to get data out of redis is quite a bit simpler than the SQL code that justifies using an ORM. | 2 | 15 | 0 | I'm learning to use SQLAlchemy connected to a SQL database for 12 standard relational tables (e.g. SQLite or PostgreSQL). But then I'd like to use Redis with Python for a couple of tables, particularly for Redis's fast set manipulation. I realise that Redis is NoSQL, but can I integrate this with SQLAlchemy for the benefit of the session and thread handling that SQLAlchemy has?
Is there a Redis SA dialect? I couldn't find it, which probably means that I'm missing some basic point. Is there a better architecture I should look at to use two different types of database? | How to integrate Redis with SQLAlchemy | 1 | 1 | 0 | 13,868 |
4,324,407 | 2010-12-01T12:36:00.000 | 14 | 0 | 0 | 0 | python,sqlalchemy,nosql,redis | 4,332,791 | 2 | false | 0 | 0 | Redis is very good at what it does, storing key values and making simple atomic operations, but if you want to use it as a relational database you're really gonna SUFFER!, as I had... and here is my story...
I've done something like that, making several objects to abstracting all the redis internals exposing primitives queries (I called filters in my code), get, set, updates, and a lot more methods that you can expect from a ORM and in fact if you are dealing only with localhost, you're not going to perceive any slowness in your application, you can use redis as a relational database but if in any time you try to move your database into another host, that will represent a lot of problems in terms of network transmission, I end up with a bunch of re-hacked classes using redis and his pipes, which it make my program like 900% faster, making it usable in the local network, anyway I'm starting to move my database library to postgres.
The lesson of this history is to never try to make a relational database with the key value model, works great at basic operations, but the price of not having the possibility to make relations in your server comes with a high cost.
Returning to your question, I don't know any project to make an adapter to sqlalchemy for redis, and I think that nobody are going to be really interested in something like that, because of the nature of each project. | 2 | 15 | 0 | I'm learning to use SQLAlchemy connected to a SQL database for 12 standard relational tables (e.g. SQLite or PostgreSQL). But then I'd like to use Redis with Python for a couple of tables, particularly for Redis's fast set manipulation. I realise that Redis is NoSQL, but can I integrate this with SQLAlchemy for the benefit of the session and thread handling that SQLAlchemy has?
Is there a Redis SA dialect? I couldn't find it, which probably means that I'm missing some basic point. Is there a better architecture I should look at to use two different types of database? | How to integrate Redis with SQLAlchemy | 1 | 1 | 0 | 13,868 |
4,325,194 | 2010-12-01T14:10:00.000 | 1 | 0 | 1 | 0 | python,regex,mongodb,datetime,database | 4,325,260 | 4 | false | 0 | 0 | I agree with the other poster. Though this doesn't solve your immediate problem, if you have any control over the database, you should seriously consider creating a time/column, with either a DATE or TIMESTAMP datatype. That would make your system much more robust, & completely avoid the problem of trying to parse dates from string (an inherently fragile technique). | 1 | 3 | 0 | I have a database full of data, including a date and time string, e.g. Tue, 21 Sep 2010 14:16:17 +0000
What I would like to be able to do is extract various documents (records) from the database based on the time contained within the date string, Tue, 21 Sep 2010 14:16:17 +0000.
From the above date string, how would I use python and regex to extract documents that have the time 15:00:00? I'm using MongoDB by the way, in conjunction with Python. | Extracting Date and Time info from a string. | 0.049958 | 1 | 0 | 563 |
4,328,223 | 2010-12-01T19:25:00.000 | 3 | 1 | 0 | 0 | python,size,byte,pyserial | 4,328,281 | 2 | false | 0 | 0 | Historically, it was common to only send ASCII text over a serial connection, which fit into seven bits, and an eighth bit would be used as a parity marker which could indicate if the data was being transmitted correctly.
Since the parity check doesn't catch errors on an even number of bits, and can't correct the data at all, it's not that valuable, and modern practice is to use 8-bit data and do error detection and correction at a higher layer of protocol.
Short answer is you probably want 8-bit, but it depends on what the other end of the serial connection is expecting.
Update:
From your other question it sounds like you're programming both ends of the connection, and checksumming your messages, so it's definitely most straightforward to use 8-bit. | 1 | 1 | 0 | I want to send messages through the serial port using PySerial. One of the parameters for the serial constructor is 'bytesize'. I have been trying serial.SEVENBITS and serial.EIGHTBITS and haven't noticed a difference. The documentation is a bit vague and I am new to both Python and serial communication.
Does this just set the maximum value a byte can hold or is it something to do with signed bytes? Can anyone clear up why I'd use 7 bits over 8?
I have been searching but haven't found an answer.
Thank you | 'bytesize' in PySerial module | 0.291313 | 0 | 0 | 4,981 |
4,328,416 | 2010-12-01T19:47:00.000 | 0 | 0 | 0 | 0 | jquery,python,html | 4,329,025 | 1 | true | 0 | 0 | Do you really want to do this?If the server is supposed to read the file with the path,why not simply upload it? Is it so large that it takes am unaceptable amount of time on an intranet? Anyway, you can probably do this with a java applet embedded. | 1 | 0 | 0 | I'm working on an intranet site, and would like to be able to click on a file (I'm not picky on how) and have the server "know" the filenme + path that I just picked. The local path is relevent because the server hosting the application has the same mapped network drive as all of the clients, so x:\someplace\something.txt is the same thing client and server side.
The obvious way was the input type="file" etc method while disabling the actual upload. The best that I've been able to come up with using this method, like countless others, is the filename. Also note that the link in a very similar sounding question to the "accepted answer" involving some onBlur workaround is broken.
The tools that I'm working with are FF3, Python/Pylons (using Mako templates) server side, and jquery client side, and am open to anything that can capture a full path without a user typing it out.
Any Ideas?
TIA,
Mike. | How to get the full path for a local file in Firefox 3 | 1.2 | 0 | 0 | 563 |
4,328,603 | 2010-12-01T20:09:00.000 | 3 | 0 | 0 | 0 | python,tkinter | 4,328,747 | 1 | false | 0 | 1 | This is not the right way to do an informational popup. On the Mac and on windows machines menus are native controls. Because of this the unpost command doesn't work because tk cedes control to the system event loop in order to get platform-specific behavior.
What you want is to use instead is a toplevel window with the overrideredirect flag set. This lets you display a borderless window anywhere you want. The upside to this is that you aren't limited to simple text -- you can put anything you want in that toplevel -- another text widget, a canvas, buttons, etc. | 1 | 1 | 0 | I have implemented an informational popup in a python app using a Tkinter Menu widget. I have a Text widget on a canvas in the root window. I created a Menu widget that has root as its parent. When I detect a mouse hover over the text widget I post the popup menu with menuWidget.post(). When I get a leave event from the text widget my intention was to have the popup disappear by calling menuWidget.unpost(), only the popup menu does not disappear until I click elsewhere outside the text widget.
First, is this a sane method for implementing an informational popup? And can anyone tell me why the popup menu won't disappear? | 'hover over' popup with Tkinter | 0.53705 | 0 | 0 | 2,151 |
4,328,681 | 2010-12-01T20:18:00.000 | 0 | 1 | 1 | 0 | python,module,profiling | 4,328,745 | 2 | false | 0 | 0 | Why not just create a branch with all the profiling changes, and then merge the branch when you want to test ... and revert everything afterwards.
git makes this somewhat easier with it's "git stash", but using branches shouldn't be significantly harder. | 1 | 0 | 0 | So I have a big project with many modules in it, and I want to run some profiling on it. I have a profile module that basically just provides a decorator that I can add to a function to profile it when it's called.
The problem is, I'll have to import that module into the dozens of modules that I have. This is fine I guess, but I can't push the code with the profiling modules imported or the decorator on the functions to version control. This means every time I import/export, I have to add/remove all my profiling code.
Is there any kind of system to manage this adding/removing of profiling code without manually importing/deleting the modules in every module of my project? We use mercurial, but I can't really mess with mercurial settings or make a branch. | python module import question | 0 | 0 | 0 | 516 |
4,328,837 | 2010-12-01T20:33:00.000 | 1 | 0 | 0 | 0 | python,algorithm,r,graph,networkx | 19,205,464 | 4 | false | 0 | 0 | I know this is very late, but you can do the same thing, albeit a little more straightforward, with mathematica.
RandomGraph[DegreeGraphDistribution[{3, 3, 3, 3, 3, 3, 3, 3}], 4]
This will generate 4 random graphs, with each node having a prescribed degree. | 2 | 7 | 1 | I am trying to generate a random graph that has small-world properties (exhibits a power law distribution). I just started using the networkx package and discovered that it offers a variety of random graph generation. Can someone tell me if it possible to generate a graph where a given node's degree follows a gamma distribution (either in R or using python's networkx package)? | Generating a graph with certain degree distribution? | 0.049958 | 0 | 0 | 9,242 |
4,328,837 | 2010-12-01T20:33:00.000 | 2 | 0 | 0 | 0 | python,algorithm,r,graph,networkx | 4,329,072 | 4 | false | 0 | 0 | I did this a while ago in base Python... IIRC, I used the following method. From memory, so this may not be entirely accurate, but hopefully it's worth something:
Chose the number of nodes, N, in your graph, and the density (existing edges over possible edges), D. This implies the number of edges, E.
For each node, assign its degree by first choosing a random positive number x and finding P(x), where P is your pdf. The node's degree is (P(x)*E/2) -1.
Chose a node at random, and connect it to another random node. If either node has realized its assigned degree, eliminate it from further selection. Repeat E times.
N.B. that this doesn't create a connected graph in general. | 2 | 7 | 1 | I am trying to generate a random graph that has small-world properties (exhibits a power law distribution). I just started using the networkx package and discovered that it offers a variety of random graph generation. Can someone tell me if it possible to generate a graph where a given node's degree follows a gamma distribution (either in R or using python's networkx package)? | Generating a graph with certain degree distribution? | 0.099668 | 0 | 0 | 9,242 |
4,329,330 | 2010-12-01T21:28:00.000 | 2 | 0 | 1 | 1 | python,windows,installation | 4,329,365 | 1 | false | 0 | 0 | My first question would be, do you have administration rights when you try to run setup.py? | 1 | 0 | 0 | I would like to install a python package to windows. I have tried to run setup.py install on command prompt but it returned an error:
could not create 'C:\Program Files\Python...': access is denied.
Please, help.
Špela | how to install a python package to windows? | 0.379949 | 0 | 0 | 240 |
4,329,377 | 2010-12-01T21:32:00.000 | 2 | 0 | 0 | 0 | button,wxpython | 4,329,486 | 1 | true | 0 | 1 | I think I would catch the EVT_LEFT_DOWN and the EVT_LEFT_UP. Then start a wx.Timer to run your process on EVT_LEFT_DOWN until the EVT_LEFT_UP is fired. Alternatively, you could use a ToggleButton. | 1 | 1 | 0 | hey all,
im looking for a way of catching a button held down event in wxpython i cant seem to find anything. theres just wx.EVT_BUTTON which isnt quite what i want. i want my event to continue processing as long as the button is down. any help would be appreciated
thanks james | wxpython button held down event | 1.2 | 0 | 0 | 1,279 |
4,330,026 | 2010-12-01T23:01:00.000 | 3 | 0 | 1 | 0 | python | 4,330,042 | 5 | false | 0 | 0 | The simplest way is to remove the letter 'S' before you create the dictionary.
Use string.ascii_uppercase.replace('S', '') instead of string.ascii_uppercase. | 2 | 1 | 0 | I need to assign the uppercase to numbers in a dictionary but with one letter S not there.
ie.
in this alphadict = dict((x, i) for i, x in enumerate(string.ascii_uppercase)) I have currently all the alphabets of the dictionary.
What is the simplest way to delete the entry for S and shift rest of the values to the left.
If there is some other way to create this dictionary do tell.....
I am also in need of this..... Now I get a number from user..... This number in the dictionary should be assigned S and all the other dictionary items can be readjusted....
ie say the user gives me 3 the dictionary should look like
0- A
1- B
2- C
3- S
and rest follow from D to Z without S.......
Please help..... Thanks a lot.... | Skip a letter in dictionary | 0.119427 | 0 | 0 | 209 |
4,330,026 | 2010-12-01T23:01:00.000 | 1 | 0 | 1 | 0 | python | 4,330,053 | 5 | false | 0 | 0 | alphadict = dict((x, i) for i, x in enumerate(string.ascii_uppercase) if x != 'S') | 2 | 1 | 0 | I need to assign the uppercase to numbers in a dictionary but with one letter S not there.
ie.
in this alphadict = dict((x, i) for i, x in enumerate(string.ascii_uppercase)) I have currently all the alphabets of the dictionary.
What is the simplest way to delete the entry for S and shift rest of the values to the left.
If there is some other way to create this dictionary do tell.....
I am also in need of this..... Now I get a number from user..... This number in the dictionary should be assigned S and all the other dictionary items can be readjusted....
ie say the user gives me 3 the dictionary should look like
0- A
1- B
2- C
3- S
and rest follow from D to Z without S.......
Please help..... Thanks a lot.... | Skip a letter in dictionary | 0.039979 | 0 | 0 | 209 |
4,330,339 | 2010-12-01T23:52:00.000 | 0 | 0 | 0 | 0 | python,model,sqlalchemy,data-modeling | 4,330,995 | 3 | false | 0 | 0 | "I would specify the column names and some attributes, e.g, type, length, etc."
Isn't that the exact same thing as
"tediously typing in all these into an SQLAlchemy model.py file"?
If those two things aren't identical, please explain how they're different. | 1 | 5 | 0 | I am implementing a database model to store the 20+ fields of the iCal calendar format and am faced with tediously typing in all these into an SQLAlchemy model.py file. Is there a smarter approach? I am looking for a GUI or model designer that can create the model.py file for me. I would specify the column names and some attributes, e.g, type, length, etc.
At the minimum, I need this designer to output a model for one table. Additional requirements, in decreasing order of priority:
Create multiple tables
Support basic relationships between the multiple tables (1:1, 1:n)
Support constraints on the columns.
I am also open to other ways of achieving the goal, perhaps using a GUI to create the tables in the database and then reflecting them back into a model.
I appreciate your feedback in advance. | Is there any database model designer that can output SQLAlchemy models? | 0 | 1 | 0 | 2,698 |
4,330,580 | 2010-12-02T00:31:00.000 | 2 | 0 | 1 | 0 | python,unicode | 4,330,599 | 3 | false | 0 | 0 | The key to understanding unicode in python is that unicode means UNICODE. A unicode object is an idealized representation to the characters, not actual bytes. | 2 | 1 | 0 | I'm trying to figure out how to use the unicode support in python;
I would like to convert this string to unicode :
"ABCDE"
-->
"\x00A\x00B\x00C\x00D\x00E"
Any built-in functionnality can do that, or shall i use join() ?
Thanks ! | python unicode support | 0.132549 | 0 | 0 | 759 |
4,330,580 | 2010-12-02T00:31:00.000 | 0 | 0 | 1 | 0 | python,unicode | 9,630,913 | 3 | false | 0 | 0 | the str object should be firstly converted to unicode object by decode method.
then convert the unicode object to str object using encode method with character-encoding you want. | 2 | 1 | 0 | I'm trying to figure out how to use the unicode support in python;
I would like to convert this string to unicode :
"ABCDE"
-->
"\x00A\x00B\x00C\x00D\x00E"
Any built-in functionnality can do that, or shall i use join() ?
Thanks ! | python unicode support | 0 | 0 | 0 | 759 |
4,331,006 | 2010-12-02T02:03:00.000 | 0 | 0 | 1 | 0 | python,recursion,persistent | 4,331,026 | 6 | false | 0 | 0 | If the object you pass is mutable then changes to it in deeper recursions will be seen in earlier recursions. | 2 | 2 | 0 | I am trying to write a recursive function that needs to store and modify an object (say a set) as it recurses. Should I use a global name inside the function? Another option is to modify or inherit the class of the parameter of the function so that it can keep this persistent object but I don't find it elegant. I could also use a stack if I would forgo the recursion altogether...
Is there a pythonic way of doing this? Could a generator do the trick? | Persistent objects in recursive python functions | 0 | 0 | 0 | 6,862 |
4,331,006 | 2010-12-02T02:03:00.000 | 2 | 0 | 1 | 0 | python,recursion,persistent | 4,331,036 | 6 | false | 0 | 0 | Pass the set into the recursive method as an argument, then modify it there before passing it to the next step. Complex objects are passed by reference. | 2 | 2 | 0 | I am trying to write a recursive function that needs to store and modify an object (say a set) as it recurses. Should I use a global name inside the function? Another option is to modify or inherit the class of the parameter of the function so that it can keep this persistent object but I don't find it elegant. I could also use a stack if I would forgo the recursion altogether...
Is there a pythonic way of doing this? Could a generator do the trick? | Persistent objects in recursive python functions | 0.066568 | 0 | 0 | 6,862 |
4,331,894 | 2010-12-02T05:12:00.000 | 1 | 0 | 0 | 0 | php,.net,python,orm,xforms | 4,349,392 | 1 | false | 1 | 0 | To answer the question: no; not that I am aware of.
This being said, XForms doesn't much to do with ORM. With XRX, it can be seen as the opposite of ORM, the goal being to avoid mapping, and the complexity it creates. If you use the same data structure (XML in the case of XRX) to hold data all the way, from your UI, to the services you call, to your database, you avoid data transformation and mapping, reducing the complexity of your system. | 1 | 0 | 0 | There are literally dozens of XML, YAML, JSON, and nested array based (that whole convention over configuration thang) standards for describing : Database tables, Classes, Maps between Tables and Classes, Constraints, User Interface descriptions, Maps between Entities and User Interfaces, Rules for user Interfaces, etc. Every major language has a system and competing standards. [http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software]
Some "patterns" like Active-Record are getting implemented in PHP, Python, Ruby, Java etc. But there is no single consensus XML or the nested array thingy de-dur. mean while back in Redmond, Microsoft is crafting XML standards for, well, everything and now with the Entity Framework they have yet another ORM standard.
Entity Framework + WPF (Windows Presentation Foundation) + WCF (Windows Communication Foundation) + WF (Windows Workflow Foundation) + LINQ (language-integrated query) = ???
I recall Mozilla's XUL was a nifty thing, but it did not include ORM. Seems like Microsoft is creating a massive set of standards, in XML, that can be used to define entire classes of applications from web, to mobile, to thin client desktop, to traditional heavy desktop app...all, incredibly...with a single set of standards.
So ... to conclude ... W3C has XForms ... but (we) need an ORM standard to move things along, something that can be implemented in PHP, Python, Ruby, Java, Objective C, Perl, Javascript, C++, and oh ya C#. If it's active record...ok...fine...but I some how think that the problem is much bigger than Active Record can handle all by itself. | Is the W3C or any standards body working on a single standard for Entity Attribute ORM definitions? | 0.197375 | 0 | 0 | 226 |
4,332,293 | 2010-12-02T06:26:00.000 | 0 | 1 | 0 | 1 | python,windows,apache,cgi,mime | 5,335,384 | 2 | true | 1 | 0 | Now I know how to solve this problem:
For windows+IIS:
While adding the application mapping(IIS), write C:\Python20\python.exe -u %s %s. I used to write like this c:\Python26\python.exe %s %s, that will create wrong mime data. And "-u" means unbuffered binary stdout and stderr.
For windows+Apache:
Add #!E:/program files/Python26/python.exe -u to the first line of the python script.
Thank Ignacio Vazquez-Abrams all the same! | 1 | 0 | 0 | I met a problem while using python(2.6) cgi to show a mime data in windows(apache).
For example, to show a image, here is my code:
image.py
#!E:/program files/Python26/python.exe
# -*- coding: UTF-8 -*-
data = open('logo.png','rb').read()
print 'Content-Type:image/png;Content-Disposition:attachment;filename=logo.png\n'
print data
But it dose not work in windows(xp or 7)+apache or IIS.
(I try to write these code in diferent way, and also try other file format, jpg and rar, but no correct output, the output data seems to be disorder in the begining lines.)
And I test these code in linux+apache, and it is Ok!
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
data = open('logo.png','rb').read()
print 'Content-Type:image/png;Content-Disposition:attachment;filename=logo.png\n'
print data
I just feel confused why it does not work in windows.
Could anybody give me some help and advice? | how to show mime data using python cgi in windows+apache | 1.2 | 0 | 0 | 381 |
4,333,359 | 2010-12-02T09:16:00.000 | 0 | 0 | 0 | 0 | python,image,label,tkinter | 4,334,872 | 1 | true | 0 | 1 | There is no built-in way to do what you want. Your own suggestions are good. Another option is to create a frame, and place separate image and label widgets in the frame. You then have complete control of the placement of the widgets | 1 | 0 | 0 | Is there a way to customize the horizontal padding between an image and text in a Label widget when compound=left or right?
The 2 ways I can think of are:
Use PIL to dynamically add columns of pixels to an image
Insert or append spaces to the text= option of the label to force the separation of image and text
What I'm looking for is a way to specify the horizontal padding (between image and text) in pixels. | Python/Tkinter: Customize horizontal padding between image and text in Label widget? | 1.2 | 0 | 0 | 912 |
4,333,711 | 2010-12-02T10:05:00.000 | 2 | 0 | 0 | 0 | python,registration | 4,333,979 | 2 | true | 1 | 0 | I've found it useful to put a verification code in the database and use it as you've suggested. The same field can do double duty for e.g. password reset requests.
I also use an expiry timeout field, where registrations or password resets need to be dealt with by the user in a timely fashion. | 1 | 1 | 0 | I am going to let new users register on my service. Here is the way I think it should go:
1. User enters his email in a field and clicks Register button.
2. User receives a confirmation email with a link containing a verification code.
3. User goes by that link from the email message where he sees a message that his account is activated now.
So, the main point I am to figure out how to implement is the second one. How do I better generate that code? Should I generate it when the user clicks Register button and save it in the field, say "verification_code" near the field "email" and then when he goes to the verification link, compare the values? Then, if that's fine, clear the "verification_code" field and set "user_is_active" field to "True". Or may be I don't have to keep that code in the database at all, but make a just in time verification with some algorithm? May be there are other things I should consider? | What is the best practice for registering a new user in my case? | 1.2 | 0 | 0 | 150 |
4,336,228 | 2010-12-02T14:47:00.000 | 4 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,338 | 12 | false | 0 | 0 | I think the Iron family of languages is primarily for adding more flavours to the platform, allowing you to get into .NET using a language that you are familiar with. It lowers the bar a lot for getting new people with different backgrounds into .NET
Even though the syntax is Python, the implementation is still built on top of the CLR and the end product will not differ a lot if you decide to go for an IronPython project instead of say C#.
I've had some experience with IronPython and find it nice to work with (it helps of course that I really like the language). IronPython is now considered a first class citizen by Microsoft, and that is also the impression you get when using it. One downside to using it though is that it isn't as widely adopted as the two main languages, causing some issues when it comes to collaboration and maintaining a code base over time.
I found it particularly useful when doing a .NET port of a search algorithm that was first implemented in Python.
Regarding adding scripting abilities to your app, that is probably not the original intention with IronPython, but it has been done. The Umbraco CMS has (or at least had) the ability to create widgets using Python as a dynamic scripting language within their platform. A pretty neat feature to have.
You should go ahead and try it out.. It's always good to have more tools in the belt :) | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.066568 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 1 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,257 | 12 | false | 0 | 0 | You can write an app in it, you can use it as a scripting language in your app.
It's used for accessing existing Python libraries and, if needed, writing parts of your code in Python if a .NET languages doesn't seem well enough suited for that job. | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.016665 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 4 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,253 | 12 | false | 0 | 0 | We use it as an embedded language inside of our software.
I had an article on my blog, but recently switched to a new system. You can find an archived version (with broken image links) here:
Our field engineers now use the embedded language to test things on the fly,
our quality assurance people use it to create small scripts to test all features of the hardware, etc....
Hope this helps. | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.066568 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 2 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,268 | 12 | false | 0 | 0 | My experience of IronPython is usage it as part of engine that can be changed after installation of base .Net application.
With help of Python we have described really large set of business rules, that can be changed from two system installation. Partially IronPython was used as plugin language.
The difference from script language - that after compilation IronPython executed as CLR code. | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.033321 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 31 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,244 | 12 | true | 0 | 0 | Either or both :)
I wouldn't claim to know a specific "purpose" for IronPython but it certainly can be used to write applications, and it can be used for scripting within a larger .NET application.
Aside from anything else, it's a handy way of gently easing Python developers into the world of .NET. (Why not learn C# at the same time? Come on in, the water's lovely...) | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 1.2 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 2 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,262 | 12 | false | 0 | 0 | You use it to write Python code that runs on the .NET platform. It's good for anything that Python is good for.
The Python language is the Python language, no matter what. IronPython is an implementation of the runtime for that language - the support code that compiles your source, creates a virtual machine to execute the bytecode in the resulting .pyc file, communicates with the OS in order to put command line arguments into sys.argv, and all that other fun stuff. (Well, OK, the .NET platform itself does a lot of the work, too. :) ) | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.033321 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 6 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,336,304 | 12 | false | 0 | 0 | IronPython is just Yet Another Python Implementation. You can use it anywhere you would use any other Python implementation. (Modulo platform constraints, of course – obviously you can't use IronPython on a Java-only device.)
IronPython is just Yet Another .NET Compiler. You can use it anywhere you would use any other .NET language.
IronPython is More Than Just Yet Another Python Implementation. It's a Python implementation that gives you full access to any .NET library.
IronPython is More Than Just Yet Another .NET Compiler. It's a .NET compiler that gives you full access to any Python library.
IronPython is an embeddable scripting engine for any .NET app, library and framework. | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 1 | 0 | 0 | 19,054 |
4,336,228 | 2010-12-02T14:47:00.000 | 1 | 1 | 1 | 0 | .net,python,ironpython,dynamic-language-runtime | 4,358,367 | 12 | false | 0 | 0 | You can use it for cool things like having an embedded web server within your application which can be developed with one of the available Python web frameworks. It is much easier and smoother to develop for than hosting an ASP.NET web server within your application. CherryPy for example comes with a builtin web server as well that should work fine with IronPython with a few small modifications. | 8 | 29 | 0 | I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for.
Could you write an app in it? or is it for adding a scripting language to your app?
How do you guys use it? | Iron Python : what are good uses for Iron Python | 0.016665 | 0 | 0 | 19,054 |
4,336,935 | 2010-12-02T15:56:00.000 | 2 | 0 | 0 | 0 | silverlight,silverlight-4.0,ironpython | 4,358,122 | 1 | true | 1 | 1 | You have to use binaries from IronPython-2.6.1\Silverlight\bin folder in Silverlight. | 1 | 3 | 0 | I am trying to integrate IronPython in my Silverlight application but am unable to do so. After downloading the binaries, every time I try to add the dlls as references in my VS2010 solution all I get is an error about them not being compiled for Silverlight. I have even tried downloading the source distribution, but cannot set the various projects making up the solution to build against Silverlight (the only choices I have are different versions of the .net framework).
As the IronPython website explicitly states Silverlight compatibility, why is it not working? Is there any easier way of getting scripting capabilities in my Silverlight app? | Ironpython 2.6.1 on Silverlight 4 | 1.2 | 0 | 0 | 127 |
4,337,736 | 2010-12-02T17:11:00.000 | 0 | 0 | 1 | 0 | python,data-structures,types | 4,338,035 | 4 | false | 0 | 0 | Include an example somewhere in your code, or in your tests. | 2 | 3 | 0 | I am quite new to python programming (C/C++ background).
I'm writing code where I need to use complex data structures like dictionaries of dictionaries of lists.
The issue is that when I must use these objects I barely remember their structure and so how to access them.
This makes it difficult to resume working on code that was untouched for days.
A very poor solution is to use comments for each variable, but that's very inflexible.
So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage? | Declaring types for complex data structures in python | 0 | 0 | 0 | 716 |
4,337,736 | 2010-12-02T17:11:00.000 | 1 | 0 | 1 | 0 | python,data-structures,types | 4,337,932 | 4 | false | 0 | 0 | I believe you should take a good look some of your complex structures, what you are doing with them, and ask... Is This Pythonic? Ask here on SO. I think you will find some cases where the complexity is an artifact of C/C++. | 2 | 3 | 0 | I am quite new to python programming (C/C++ background).
I'm writing code where I need to use complex data structures like dictionaries of dictionaries of lists.
The issue is that when I must use these objects I barely remember their structure and so how to access them.
This makes it difficult to resume working on code that was untouched for days.
A very poor solution is to use comments for each variable, but that's very inflexible.
So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage? | Declaring types for complex data structures in python | 0.049958 | 0 | 0 | 716 |
4,338,474 | 2010-12-02T18:30:00.000 | 2 | 0 | 1 | 0 | python,arrays,oop,object | 4,338,526 | 6 | true | 0 | 0 | No. The object could be inside everything and multiple objects at the same time, so it can't know unless you tell it. | 4 | 0 | 0 | Is there a way in Python for an object to 'know' what its array element id is? I.e 6 in an array, and the object itself prints out its own array element number, so '0,1,2,3,4,5' | Python Object awareness of being in an array? | 1.2 | 0 | 0 | 172 |
4,338,474 | 2010-12-02T18:30:00.000 | -1 | 0 | 1 | 0 | python,arrays,oop,object | 4,338,640 | 6 | false | 0 | 0 | If the object knows the list it is part of, it could find out by doing the_list.index(self). Otherwise, no. | 4 | 0 | 0 | Is there a way in Python for an object to 'know' what its array element id is? I.e 6 in an array, and the object itself prints out its own array element number, so '0,1,2,3,4,5' | Python Object awareness of being in an array? | -0.033321 | 0 | 0 | 172 |
4,338,474 | 2010-12-02T18:30:00.000 | 2 | 0 | 1 | 0 | python,arrays,oop,object | 4,338,520 | 6 | false | 0 | 0 | In a word, no... | 4 | 0 | 0 | Is there a way in Python for an object to 'know' what its array element id is? I.e 6 in an array, and the object itself prints out its own array element number, so '0,1,2,3,4,5' | Python Object awareness of being in an array? | 0.066568 | 0 | 0 | 172 |
4,338,474 | 2010-12-02T18:30:00.000 | 0 | 0 | 1 | 0 | python,arrays,oop,object | 4,338,679 | 6 | false | 0 | 0 | Not unless you tell it, and telling it leads to very annoying coupling and/or separation of responsibility problems. What are you really trying to do? | 4 | 0 | 0 | Is there a way in Python for an object to 'know' what its array element id is? I.e 6 in an array, and the object itself prints out its own array element number, so '0,1,2,3,4,5' | Python Object awareness of being in an array? | 0 | 0 | 0 | 172 |
4,339,325 | 2010-12-02T20:05:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,bulkloader | 4,340,593 | 1 | true | 1 | 0 | Defining a custom conversion function, as you did, is the correct method. You don't have to modify transform.py, though - put the function in a file in your own app, and import it in the yaml file's python_preamble. | 1 | 1 | 0 | I have successfully used the bulkloader with my project before, but I recently added a new field to timestamp when the record was modified. This new field is giving me trouble, though, because it's defaulting to null. Short of manually inserting the timestamp in the csv before importing it, is there a way I can insert the current right data? I assume I need to look toward the import_transform line, but I know nothing of Python (my app is in Java).
Ideally, I'd like to insert the current timestamp (milliseconds since epoch) automatically. If that's non-trivial, maybe set the value statically in the transform statement before running the import. Thanks. | Generating a default value with the Google App Engine Bulkloader | 1.2 | 0 | 0 | 296 |
4,339,708 | 2010-12-02T20:51:00.000 | 4 | 0 | 1 | 0 | python | 4,339,741 | 1 | true | 0 | 0 | Try hasattr(). | 1 | 0 | 0 | I have an lxml object called item and it may have a child called item.brand, however it's possible that there is none as this is returned from an API. How can I check this in Python? | How can I see if a child exists in Python? | 1.2 | 0 | 1 | 706 |
4,339,745 | 2010-12-02T20:53:00.000 | 2 | 0 | 1 | 0 | python,scapy | 4,339,911 | 1 | true | 0 | 0 | got it , from the version v.2 onward the it should be used as from scapy.all import * | 1 | 1 | 0 | i am trying to use scapy in python
while i try to import the scapy import scapy
its just fine but the line scapy.ARP() causes a
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'module' object has no attribute 'ARP'
a dir(scapy) produces
'['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__']'
what might be the problem here ? do i need to install the packages separately if yes how to do it ? | ARP missing from the module scapy | 1.2 | 0 | 0 | 1,937 |
4,340,873 | 2010-12-02T22:55:00.000 | 1 | 0 | 1 | 0 | python,python-3.x,python-2.6 | 4,340,917 | 12 | false | 0 | 0 | Yes you can. On my machine at least(Vista), v2 and v3 have completely separate idles allowing me to run whichever version I feel like when I feel like it. So go ahead and download v3. | 3 | 45 | 0 | I am reading How To Learn Python The Hard Way, which uses 2. Recently discovered Invent With Python, which uses 3.
Can I download python 3, and use it when I read Invent With Python, then switch back to python 2 when I want to read How To Learn Python The Hard Way. If so, how would I choose which version I use? | How do you switch between python 2 and 3, and vice versa? | 0.016665 | 0 | 0 | 97,645 |
4,340,873 | 2010-12-02T22:55:00.000 | 1 | 0 | 1 | 0 | python,python-3.x,python-2.6 | 43,423,351 | 12 | false | 0 | 0 | if you are using windows 10 and have python 2.x and 3.x.
open control panel > system and security > system
click advanced system settings.
click environment variables.
click path and edit and then make the path of python version you want to use above that you don't want to use [by click the moveu Up button]
restart powershell.
python --version | 3 | 45 | 0 | I am reading How To Learn Python The Hard Way, which uses 2. Recently discovered Invent With Python, which uses 3.
Can I download python 3, and use it when I read Invent With Python, then switch back to python 2 when I want to read How To Learn Python The Hard Way. If so, how would I choose which version I use? | How do you switch between python 2 and 3, and vice versa? | 0.016665 | 0 | 0 | 97,645 |
4,340,873 | 2010-12-02T22:55:00.000 | 1 | 0 | 1 | 0 | python,python-3.x,python-2.6 | 4,340,933 | 12 | false | 0 | 0 | A couple ways on *nix systems:
Install into separate directories (e.g. /usr/local/python2 and /usr/local/python3) and create a link (e.g. /usr/bin/python) which you change to point to whichever executable you want to use.
Same install as above, but set up separate python commands (e.g. /usr/bin/python2 and /usr/bin/python3) and call those when you want to invoke python. Or have the python command default to one of those and a pythonN for the other (N = 2 or 3, whichever isn't the default). | 3 | 45 | 0 | I am reading How To Learn Python The Hard Way, which uses 2. Recently discovered Invent With Python, which uses 3.
Can I download python 3, and use it when I read Invent With Python, then switch back to python 2 when I want to read How To Learn Python The Hard Way. If so, how would I choose which version I use? | How do you switch between python 2 and 3, and vice versa? | 0.016665 | 0 | 0 | 97,645 |
4,341,746 | 2010-12-03T01:41:00.000 | 1 | 0 | 1 | 0 | python,pylint | 48,765,416 | 13 | false | 0 | 1 | Python syntax does permit more than one statement on a line, separated by semicolon (;). However, limiting each line to one statement makes it easier for a human to follow a program's logic when reading through it.
So, another way of solving this issue, is to understand why the lint message is there and not put more than one statement on a line.
Yes, you may find it easier to write multiple statements per line, however, Pylint is for every other reader of your code not just you. | 1 | 346 | 0 | I'm trying to disable warning C0321 ("more than one statement on a single line" -- I often put if statements with short single-line results on the same line), in Pylint 0.21.1 (if it matters: astng 0.20.1, common 0.50.3, and Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)).
I've tried adding disable=C0321 in the Pylint configuration file, but Pylint insists on reporting it anyway. Variations on that line (like disable=0321 or disable=C321) are flagged as errors, so Pylint does recognize the option properly. It's just ignoring it.
Is this a Pylint bug, or am I doing something wrong? Is there a way around this?
I'd really like to get rid of some of this noise. | How do I disable a Pylint warning? | 0.015383 | 0 | 0 | 404,539 |
4,342,176 | 2010-12-03T03:24:00.000 | 1 | 0 | 1 | 0 | python,string,list,serialization,dictionary | 4,342,203 | 9 | false | 0 | 0 | While not strictly serialization, json may be reasonable approach here. That will handled nested dicts and lists, and data as long as your data is "simple": strings, and basic numeric types. | 1 | 79 | 0 | How do I serialize a Python dictionary into a string, and then back to a dictionary? The dictionary will have lists and other dictionaries inside it. | How do I serialize a Python dictionary into a string, and then back to a dictionary? | 0.022219 | 0 | 0 | 138,127 |
4,343,014 | 2010-12-03T06:23:00.000 | 9 | 1 | 1 | 1 | c#,java,python,perl,programming-languages | 4,343,035 | 5 | false | 0 | 0 | As with a great many things in IT, the line is blurry. For example, C started its life as a systems programming language (and was used to implement Unix), but was and is used for applications development too.
Having said that, there are clearly some languages better suited to systems programming than others (eg. C/C++ are better suited than COBOL/FORTRAN for systems programming). Likewise there are languages that are better suited to applications development and not systems programming eg. VB.NET.
The language features that stand out from the examples above, are the low level features of the systems programming languages like C/C++ (eg. pointers, bit manipulation operators, etc). There is of course the old joke that C is a "Sea" level language (sitting somewhere between the assembly level and the "high" level).
Warning: I'm coming at systems programming from the perspective of OS developer / OS tool developer.
I think it is fair to say, notwithstanding the projects to develop OSes with Java (though I believe mostly are native compiled, rather than to byte code and JIT'ed / interpreted), that systems programming languages target native machine code of their target platforms. So languages that primarily target managed code / interpreted code are less likely to be used for systems programming.
Anyway, that is surely enough to stir up some comments both in support and in opposition :) | 5 | 13 | 0 | What are the differences between a systems programming language and Application programming language? | Difference between Systems programming language and Application programming languages | 1 | 0 | 0 | 13,401 |
4,343,014 | 2010-12-03T06:23:00.000 | 16 | 1 | 1 | 1 | c#,java,python,perl,programming-languages | 4,343,639 | 5 | true | 0 | 0 | A few factors should in my opinon come into consideration
In a system programming language you must be able to reach low-level stuff, getting close to the real hardware world. In an application language instead there is a sort of "virtual world" (hopefully nicer and easier to interact with) that has been designed with the language and you only need to be able to cope with that.
In a system programming language there should be no concession in terms of performance. One must be able to write code that squeezes out all the juice from the hardware. This is not the biggest concern in an application programming language, where the time needed to actually write the program plays instead a greater role.
Because of 2 a system programming language is free to assume that the programmer makes no mistake and so there will be no "runtime error" guards. For example indexing out of an array is going to mean the end of the world unless the hardware gives those checks for free (but in that case you could probably choose less expensive or faster hardware instead). The idea is that if you assume that the code is correct there is no point in paying even a small price for checking the impossible. Also a system programming language shouldn't get into the way trying to forbid the programmer doing something s/he wants to do intentionally... the assumption is that s/he knows that is the right thing to do. In an application programming language instead it's considered good helping the programmer with checking code and also trying to force the code to use certain philosophical schemas. In application programming languages things like execution speed, typing time and code size can be sacrificed trying to help programmers avoiding shooting themselves.
Because of 3 a system programming language will be much harder to learn by experimentation. In a sense they're sort of powerful but dangerous tools that one should use carefully thinking to every single statement and for the same reason they're languages where debugging is much harder. In application programming languages instead the try-and-see approach may be reasonable (if the virtual world abstraction is not leaking too much) and letting errors in to remove them later is considered a viable option. | 5 | 13 | 0 | What are the differences between a systems programming language and Application programming language? | Difference between Systems programming language and Application programming languages | 1.2 | 0 | 0 | 13,401 |
4,343,014 | 2010-12-03T06:23:00.000 | 5 | 1 | 1 | 1 | c#,java,python,perl,programming-languages | 4,343,077 | 5 | false | 0 | 0 | These are not exact concepts, but in essence, systems programming languages are suitable for writing operating systems (so they have low-level concepts such as pointers, integration with assembler, data types corresponding to memory and register organization), while the application programming languages are more suitable for writing applications, so they generally use higher-level concepts to represent the computation (such as OOP, closures, in-built complex datatypes and so on). | 5 | 13 | 0 | What are the differences between a systems programming language and Application programming language? | Difference between Systems programming language and Application programming languages | 0.197375 | 0 | 0 | 13,401 |
4,343,014 | 2010-12-03T06:23:00.000 | 2 | 1 | 1 | 1 | c#,java,python,perl,programming-languages | 4,343,085 | 5 | false | 0 | 0 | In general, a systems programming language is lower level than applications programming languages. However, the language itself has nothing to do with it.. it's more the particulars of the implementation of the language.
For example, Pascal started life as a teaching language, and was pretty much strictly applications.. however, it was evolved into a systems language and was used to create early versions of MacOS and Windows.
C# is not, typically a systems language because it cannot do low-level work, although even that line is blurred as managed operating systems come into being. | 5 | 13 | 0 | What are the differences between a systems programming language and Application programming language? | Difference between Systems programming language and Application programming languages | 0.07983 | 0 | 0 | 13,401 |
4,343,014 | 2010-12-03T06:23:00.000 | 2 | 1 | 1 | 1 | c#,java,python,perl,programming-languages | 4,350,156 | 5 | false | 0 | 0 | i don't think there is a final answer here anymore.
perl and python come by default with almost every linux distro...both can inline C...both can do job control and other "low level" tasks...threading etc.
any language with a good set of system call bindings and/or FFI should be as fundamentally system-aware as C or C++.
the only languages i would discount as being systems languages are those that specifically address another platform (jvm, clr) and actively seek to prevent native interaction | 5 | 13 | 0 | What are the differences between a systems programming language and Application programming language? | Difference between Systems programming language and Application programming languages | 0.07983 | 0 | 0 | 13,401 |
4,343,575 | 2010-12-03T08:07:00.000 | 2 | 0 | 0 | 1 | python,networking,bonjour,zeroconf | 4,343,600 | 4 | false | 0 | 0 | Zeroconf/DNS-SD is an excellent idea in this case. It's provided by Bonjour on OS X and Windows (but must be installed separately or as part of an Apple product on Windows), and by Avahi on FOSS *nix. | 1 | 2 | 0 | My app opens a TCP socket and waits for data from other users on the network using the same application. At the same time, it can broadcast data to a specified host on the network.
Currently, I need to manually enter the IP of the destination host to be able to send data. I want to be able to find a list of all hosts running the application and have the user pick which host to broadcast data to.
Is Bonjour/ZeroConf the right route to go to accomplish this? (I'd like it to cross-platform OSX/Win/*Nix) | Proper way to publish and find services on a LAN using Python | 0.099668 | 0 | 1 | 1,210 |
4,344,017 | 2010-12-03T09:16:00.000 | 16 | 0 | 1 | 0 | python,concatenation,sequence,list-manipulation | 4,345,688 | 7 | false | 0 | 0 | Just to let you know:
When you write list1 + list2, you are calling the __add__ method of list1, which returns a new list. in this way you can also deal with myobject + list1 by adding the __add__ method to your personal class. | 3 | 699 | 0 | In Python, the only way I can find to concatenate two lists is list.extend, which modifies the first list. Is there any concatenation function that returns its result without modifying its arguments? | How can I get the concatenation of two lists in Python without modifying either one? | 1 | 0 | 0 | 909,604 |
4,344,017 | 2010-12-03T09:16:00.000 | 117 | 0 | 1 | 0 | python,concatenation,sequence,list-manipulation | 4,344,032 | 7 | false | 0 | 0 | concatenated_list = list_1 + list_2 | 3 | 699 | 0 | In Python, the only way I can find to concatenate two lists is list.extend, which modifies the first list. Is there any concatenation function that returns its result without modifying its arguments? | How can I get the concatenation of two lists in Python without modifying either one? | 1 | 0 | 0 | 909,604 |
4,344,017 | 2010-12-03T09:16:00.000 | 1,147 | 0 | 1 | 0 | python,concatenation,sequence,list-manipulation | 4,344,029 | 7 | true | 0 | 0 | Yes: list1 + list2. This gives a new list that is the concatenation of list1 and list2. | 3 | 699 | 0 | In Python, the only way I can find to concatenate two lists is list.extend, which modifies the first list. Is there any concatenation function that returns its result without modifying its arguments? | How can I get the concatenation of two lists in Python without modifying either one? | 1.2 | 0 | 0 | 909,604 |
4,345,337 | 2010-12-03T12:04:00.000 | 3 | 0 | 0 | 0 | python,python-imaging-library,imaging | 4,345,485 | 1 | true | 0 | 0 | You might want to look into converting your image to a numpy array, performing your quantisation, then converting back to PIL.
There are modules in numpy to convert to/from PIL images. | 1 | 4 | 1 | I would like to quantize a 24bit image to 16bit color depth using Python Imaging.
PIL used to provide a method im.quantize(colors, **options) however this has been deprecated for out = im.convert("P", palette=Image.ADAPTIVE, colors=256)
Unfortunately 256 is the MAXIMUM number of colors that im.convert() will quantize to (8 bit only).
How can I quantize a 24bit image down to 16bit using PIL (or similar)?
thanks | Python Imaging, how to quantize an image to 16bit depth? | 1.2 | 0 | 0 | 4,447 |
4,346,318 | 2010-12-03T14:08:00.000 | 1 | 0 | 0 | 1 | python,django,profiling,memory-management,celery | 4,349,979 | 4 | false | 1 | 0 | The natural number of workers is close to the number of cores you have. The workers are there so that cpu-intensive tasks can use an entire core efficiently. The broker is there so that requests that don't have a worker on hand to process them are kept queued. The number of queues can be high, but that doesn't mean you need a high number of brokers either. A single broker should suffice, or you could shard queues to one broker per machine if it later turns out fast worker-queue interaction is beneficial.
Your problem seems unrelated to that. I'm guessing that your agencies don't provide a message queue api, and you have to keep around lots of requests. If so, you need a few (emphasis on not many) evented processes, for example twisted or node.js based. | 1 | 13 | 0 | We have ~300 celeryd processes running under Ubuntu 10.4 64-bit , in idle every process takes ~19mb RES, ~174mb VIRT, thus - it's around 6GB of RAM in idle for all processes.
In active state - process takes up to 100mb of RES and ~300mb VIRT
Every process uses minidom(xml files are < 500kb, simple structure) and urllib.
Quetions is - how can we decrease RAM consuption - at least for idle workers, probably some celery or python options may help?
How to determine which part takes most of memory?
UPD: thats flight search agents, one worker for one agency/date. We have 10 agencies, one user search == 9 dates, thus we have 10*9 agents per one user search.
Is it possible start celeryd processes on demand to avoid idle workers(something like MaxSpareServers on apache)?
UPD2: Agent lifecycle is - send HTTP request, wait for response ~10-20 sec, parse xml( takes less then 0.02s), save result to MySQL | Celery - minimize memory consumption | 0.049958 | 0 | 0 | 19,420 |
4,348,061 | 2010-12-03T17:15:00.000 | 21 | 0 | 1 | 0 | python,json,urllib2 | 7,469,725 | 4 | false | 0 | 0 | For Python 3.x
Note the following
In Python 3.x the urllib and urllib2 modules have been combined. The module is named urllib. So, remember that urllib in Python 2.x and urllib in Python 3.x are DIFFERENT modules.
The POST data for urllib.request.Request in Python 3 does NOT accept a string (str) -- you have to pass a bytes object (or an iterable of bytes)
Example
pass json data with POST in Python 3.x
import urllib.request
import json
json_dict = { 'name': 'some name', 'value': 'some value' }
# convert json_dict to JSON
json_data = json.dumps(json_dict)
# convert str to bytes (ensure encoding is OK)
post_data = json_data.encode('utf-8')
# we should also say the JSON content type header
headers = {}
headers['Content-Type'] = 'application/json'
# now do the request for a url
req = urllib.request.Request(url, post_data, headers)
# send the request
res = urllib.request.urlopen(req)
# res is a file-like object
# ...
Finally note that you can ONLY send a POST request if you have SOME data to send.
If you want to do an HTTP POST without sending any data, you should send an empty dict as data.
data_dict = {}
post_data = json.dumps(data_dict).encode()
req = urllib.request.Request(url, post_data)
res = urllib.request.urlopen(req) | 1 | 16 | 0 | I want to use python urllib2 to simulate a login action, I use Fiddler to catch the packets and got that the login action is just an ajax request and the username and password is sent as json data, but I have no idea how to use urllib2 to send json data, help... | How to use python urllib2 to send json data for login | 1 | 0 | 1 | 32,746 |
4,348,658 | 2010-12-03T18:30:00.000 | 0 | 0 | 0 | 0 | python,sqlite | 4,348,768 | 3 | false | 0 | 0 | Just execute sqlite3 foo.db? This will permanently store everything you do afterwards in this file. (No need for .backup.) | 1 | 0 | 0 | I just downloaded sqlite3.exe. It opens up as a command prompt. I created a table test & inserted a few entries in it. I used .backup test just in case. After I exit the program using .exit and reopened it I don't find the table listed under .tables nor can I run any query on it.
I need to quickly run an open source python program that makes use of this table & although I have worked with MySQL, I have no clue about sqlite. I need the minimal basics of sqlite. Can someone guide me through this or at least tell me how to permanently store my tables.
I have put this sqlite3.exe in Python folder assuming that python would then be able to read the sqlite files. Any ideas on this? | How to create tables in sqlite 3? | 0 | 1 | 0 | 2,598 |
4,348,660 | 2010-12-03T18:30:00.000 | 1 | 1 | 1 | 0 | python,file,compression | 4,348,705 | 2 | false | 0 | 0 | If you would like to learn more about how file compression works, the code is available right in the python source code in the file gzip.py. You should also check out the zlib source code, on which the gzip module is based.
You can get zlib source code from zlib.net. | 1 | 1 | 0 | python programmers,
I'm am new to python ,I read that we have built in functions to achieve file compression in python . I just wanted to know if a file compression can be done without using these built in functions (maybe a longer code perhaps) .I wanted to understand the working of these built in functions(how they are coded) basically .
forgive the fallacies(if any) of a beginner,
thanks in advance | file compression without using built in functions | 0.099668 | 0 | 0 | 419 |
4,348,707 | 2010-12-03T18:37:00.000 | 1 | 0 | 0 | 0 | python,html | 4,348,712 | 2 | false | 1 | 0 | It will be a simple GET request, just like any other resource embedded in an HTML document.
If you really want to examine exactly what browsers send, then use something like Charles or the Net tab of Firebug. | 2 | 0 | 0 | I am iusing in my html. I am trying to handle the request on server side using python BaseHTTPServer. I want to figure out how the request from video tag looks like??? | is Video tag in html a POST request or GET request? | 0.099668 | 0 | 1 | 513 |
4,348,707 | 2010-12-03T18:37:00.000 | 0 | 0 | 0 | 0 | python,html | 4,348,815 | 2 | false | 1 | 0 | POST is usually reserved for form submissions because you are POSTing form information to the server. In this case you are just GETing the contents of a <video> source. | 2 | 0 | 0 | I am iusing in my html. I am trying to handle the request on server side using python BaseHTTPServer. I want to figure out how the request from video tag looks like??? | is Video tag in html a POST request or GET request? | 0 | 0 | 1 | 513 |
4,348,733 | 2010-12-03T18:41:00.000 | 2 | 0 | 0 | 0 | python,matplotlib | 4,348,902 | 7 | false | 0 | 0 | Good question. Here is the doc text from pylab.save:
pylab no longer provides a save function, though the old pylab
function is still available as matplotlib.mlab.save (you can still
refer to it in pylab as "mlab.save"). However, for plain text
files, we recommend numpy.savetxt. For saving numpy arrays,
we recommend numpy.save, and its analog numpy.load, which are
available in pylab as np.save and np.load. | 1 | 144 | 1 | Is there a way to save a Matplotlib figure such that it can be re-opened and have typical interaction restored? (Like the .fig format in MATLAB?)
I find myself running the same scripts many times to generate these interactive figures. Or I'm sending my colleagues multiple static PNG files to show different aspects of a plot. I'd rather send the figure object and have them interact with it themselves. | Saving interactive Matplotlib figures | 0.057081 | 0 | 0 | 98,342 |
4,349,714 | 2010-12-03T20:46:00.000 | 0 | 0 | 1 | 0 | python,class | 4,349,752 | 5 | false | 0 | 0 | You can organize it in whatever way makes the most sense for your application. I don't exactly know what you're doing so I can't be certain what the best organization would be for you, but you can pretty much split it up as you see fit and just import what you need.
You can define classes in any file, and you can define as many classes as you would like in a script (unlike Java). There are no official header files (not like C or C++), but you can use config files to store info about connecting to a DB, whatever, and use configparser (a standard library function) to organize them.
It makes sense to keep like things in the same file, so if you have a GUI, you might have one file for the interface, and if you have a CLI, you might keep that in a file by itself. It's less important how your files are organized and more important how the source is organized into classes and functions. | 1 | 1 | 0 | I am doing some heavy commandline stuff (not really web based) and am new to Python, so I was wondering how to set up my files/folders/etc. Are there "header" files where I can keep all the DB connection stuff?
How/where do I define classes and objects? | How is a Python project set up? | 0 | 0 | 0 | 1,866 |
4,350,627 | 2010-12-03T22:53:00.000 | 3 | 1 | 1 | 1 | python,eclipse | 4,350,649 | 4 | false | 0 | 0 | I'd suggest using a version control system.
Git might be good for you - it doesn't require a central server and there is also support for Windows these days. | 2 | 3 | 0 | I'm currently in college, and we work in groups of three to create small python projects on a weekly basis.
We code with Eclipse and PyDev but we've got a problem when it comes to sharing our work. We end up sending an infinite stream of emails with compressed projects.
What we need is a way to keep the source code updated and we need to be able to share it between us. (on both Windows and Linux) What do you recommend?
thanks in advance. | Code sharing between small student group | 0.148885 | 0 | 0 | 582 |
4,350,627 | 2010-12-03T22:53:00.000 | 1 | 1 | 1 | 1 | python,eclipse | 4,350,652 | 4 | false | 0 | 0 | What you need is a control version server (SVN for instance). You will be able to commit the changes and update the local version of your code to the current server version.
It is for free:
http://code.google.com/
You should set up your repo and share your work! :-)
I hope it helps. | 2 | 3 | 0 | I'm currently in college, and we work in groups of three to create small python projects on a weekly basis.
We code with Eclipse and PyDev but we've got a problem when it comes to sharing our work. We end up sending an infinite stream of emails with compressed projects.
What we need is a way to keep the source code updated and we need to be able to share it between us. (on both Windows and Linux) What do you recommend?
thanks in advance. | Code sharing between small student group | 0.049958 | 0 | 0 | 582 |
4,350,879 | 2010-12-03T23:31:00.000 | 2 | 0 | 1 | 0 | python | 4,350,903 | 6 | false | 0 | 0 | 'man expand' for some info
it's in coreutils on Debian | 2 | 6 | 0 | I have some tab formatted code in python and I have some space formatted code in python.
Integrating the code in a pain... my editor wants to work in tabs or spaces, but not both.
Is there a command line function in linux or, well, anything which will convert python code formatting one way or the other? | converting white space in python files? | 0.066568 | 0 | 0 | 752 |
4,350,879 | 2010-12-03T23:31:00.000 | 0 | 0 | 1 | 0 | python | 4,351,098 | 6 | false | 0 | 0 | A good programmer's editor will have a command that converts tabs to spaces or vice/versa; you can also do it with search-and-replace in the editor. | 2 | 6 | 0 | I have some tab formatted code in python and I have some space formatted code in python.
Integrating the code in a pain... my editor wants to work in tabs or spaces, but not both.
Is there a command line function in linux or, well, anything which will convert python code formatting one way or the other? | converting white space in python files? | 0 | 0 | 0 | 752 |
4,351,048 | 2010-12-04T00:06:00.000 | 4 | 0 | 1 | 0 | python,unit-testing,cross-platform,temporary-files,ramdisk | 4,351,289 | 4 | false | 0 | 0 | Because file and directory-handling is so low-level and OS dependent, I doubt anything like what you want exists (or is even possible). Your best bet might be to implement a "virtual" file-system-like set of functions, classes, and methods that keep track of the files and directory-hierarchy created and their content.
Callables in such an emulation would need to have the same signature and return the same value(s) as their counterparts in the various Python standard built-ins and modules your application uses.
I suspect this might not be as much work as it sounds -- emulating the standard Python file-system interface -- depending on how much of it you're actually using since you wouldn't necessarily have to imitate all of it. Also, if written in Pure Python™, it would also be portable and easy to maintain and enhance. | 2 | 47 | 0 | I want to create a ramdisk in Python. I want to be able to do this in a cross-platform way, so it'll work on Windows XP-to-7, Mac, and Linux. I want to be able to read/write to the ramdisk like it's a normal drive, preferably with a drive letter/path.
The reason I want this is to write tests for a script that creates a directory with a certain structure. I want to create the directory completely in the ramdisk so I'll be sure it would be completely deleted after the tests are over. I considered using Python's tempfile, but if the test will be stopped in the middle the directory might not be deleted. I want to be completely sure it's deleted even if someone pulls the plug on the computer in the middle of a test. | How can I create a ramdisk in Python? | 0.197375 | 0 | 0 | 21,157 |
4,351,048 | 2010-12-04T00:06:00.000 | 1 | 0 | 1 | 0 | python,unit-testing,cross-platform,temporary-files,ramdisk | 4,351,325 | 4 | false | 0 | 0 | One option might be to inject (monkey patch) modified versions of the methods used in the os module as well as the builtins open and file that write to StringIO files instead of to disk. Obviously this substitution should only occur for the module being tested; | 2 | 47 | 0 | I want to create a ramdisk in Python. I want to be able to do this in a cross-platform way, so it'll work on Windows XP-to-7, Mac, and Linux. I want to be able to read/write to the ramdisk like it's a normal drive, preferably with a drive letter/path.
The reason I want this is to write tests for a script that creates a directory with a certain structure. I want to create the directory completely in the ramdisk so I'll be sure it would be completely deleted after the tests are over. I considered using Python's tempfile, but if the test will be stopped in the middle the directory might not be deleted. I want to be completely sure it's deleted even if someone pulls the plug on the computer in the middle of a test. | How can I create a ramdisk in Python? | 0.049958 | 0 | 0 | 21,157 |
4,353,019 | 2010-12-04T10:08:00.000 | 1 | 0 | 1 | 0 | python,image,compression,python-imaging-library | 4,353,063 | 4 | false | 0 | 0 | a) change the size: Image.resize(size, filter) b) explicitly convert it to JPEG (if it is not) and set the desired quality. c) use a combination of a) and b)
Whatever you do, there is a trade-off between size and quality. | 1 | 8 | 0 | I want to degrade the quality of the image to a few kilobytes.
What's the best way to do this?
Thanks! | In Python's PIL, how do I change the quality of an image? | 0.049958 | 0 | 0 | 11,769 |
4,353,491 | 2010-12-04T12:29:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,cookies | 4,368,390 | 2 | false | 1 | 0 | As mentioned above gaeutilties provides sessions support. If that's what you're looking for overall you may want to check it out.
However, also to answer your question. Cookies set persist between requests, you don't need to keep resetting it unless you the expiration extremely low. If you do not set an expiration the cookie will persist until the browser is closed. | 1 | 1 | 0 | I want to set some value to cookie when user visits the homepage so that when he hits some url I'll get that value and compare it with what I've stored in db. Now do I have to set the same cookie value again to handle the next request(in order to maintain session).
I'm using python on GAE and I couldn't find any session service available. So the way I've chosen is it the correct one? or Is there any other way to recognize the user?
Any tutorial on session maintaining and cookie handling on python will also be very helpful.
I'm using python 2.6 with django on GAE.
Thanks | Need some help on Cookie Handling and session in python | 0.099668 | 0 | 0 | 383 |
4,354,647 | 2010-12-04T16:58:00.000 | 4 | 0 | 0 | 1 | python,google-app-engine | 4,355,054 | 1 | true | 1 | 0 | No.
However, you could get the desired behavior if you write your own deployment script. This script could be a thin wrapper around appcfg.py which makes a request to your app once the deployment is complete (the request handler can execute the logic you wanted to put in your "deploy hook"). | 1 | 5 | 0 | I want to increase the version number on a model whenever there is a new deployment to the server.
So the idea behind this is: Everytime there is a deployment I wanna run some code.
Is this possible within App Engine using hooks or events?
I'm using App Engine for Python. | Does app engine have a Deploy Hook or Event? | 1.2 | 0 | 0 | 525 |
4,354,894 | 2010-12-04T17:47:00.000 | 1 | 0 | 1 | 0 | python,macos,mp3,decode | 4,354,935 | 4 | true | 0 | 0 | I did try an easy_install of PyMedia on OS X / Fink, and it did not work because it could not find the source. This module does look quite dead…
One way of decoding MP3 is to call ffmpeg without going through pyffmpeg, but by calling ffmpeg using the standard subprocess module instead. | 1 | 7 | 0 | I need to decode an MP3 file with Python. What is a good library which can do that?
I looked at PyMedia but the project seems dead and it didn't worked on MacOSX. Then I found out about pyffmpeg but I didn't got it working on MacOSX so far.
Any suggestion? | Python: decode mp3 | 1.2 | 0 | 0 | 4,285 |
4,354,963 | 2010-12-04T18:00:00.000 | 0 | 0 | 0 | 0 | python,audio,midi | 4,355,275 | 4 | false | 0 | 0 | Is using Jython an option ?
I think the javax.sound.midi classes would handle this. | 1 | 10 | 0 | I need convert/synthesize MIDI data to audio stream PCM data. What would be an easy way to do so? | Python: midi to audio stream | 0 | 0 | 0 | 7,115 |
4,355,435 | 2010-12-04T19:41:00.000 | 0 | 0 | 0 | 0 | python,excel | 4,355,455 | 4 | false | 0 | 0 | The easiest way would be to run excel up under Wine or as a VM and do it from Windows. You can use Mark Hammond's COM bindings, which come bundled with ActiveState Python. Alternatively, you could export the data in CSV format and read it from that. | 1 | 3 | 0 | I have some (Excel 2000) workbooks. I want to extract the data in each worksheet to a separate file.
I am running on Linux.
Is there a library I can use to access (read) XLS files on Linux from Python? | Cross platform way to read Excel files in Python? | 0 | 1 | 0 | 2,104 |
4,355,909 | 2010-12-04T21:24:00.000 | 0 | 0 | 0 | 0 | python,mysql,ruby-on-rails,nosql | 4,357,332 | 3 | false | 1 | 0 | The NoSQL effort has to do with creating a persistence layer that scales with modern applications using non-normalized data structures for fast reads & writes and data formats like JSON, the standard format used by ajax based systems. It is sometimes the case that transaction based relational databases do not scale well, but more often than not poor performance is directly related to poor data modeling, poor query creation and poor planning.
No persistence layer should have anything to do with your domain model. Using a data abstraction layer, you transform the data contained in your objects to the schema implemented in your data store. You would then use the same DAL to read data from your data store, transform and load it into your objects.
Your data store could be XML files, an RDBMS like SQL Server or a NoSQL implementation like CouchDB. It doesn't matter.
FWIW, I've built and inherited plenty of applications that used no model at all. For some, there's no need, but if you're using an object model it has to fit the needs of the application, not the data store and not the presentation layer. | 3 | 0 | 0 | With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql?
Note
I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar. | With the rise of NoSQL, Is it more common these days to have a webapp without any model? | 0 | 1 | 0 | 210 |
4,355,909 | 2010-12-04T21:24:00.000 | 0 | 0 | 0 | 0 | python,mysql,ruby-on-rails,nosql | 4,355,924 | 3 | false | 1 | 0 | SQL databases are still the order of the day. But it's becoming more common to use unstructured stores. NoSQL databases are well suited for some web apps, but not necessarily all of them. | 3 | 0 | 0 | With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql?
Note
I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar. | With the rise of NoSQL, Is it more common these days to have a webapp without any model? | 0 | 1 | 0 | 210 |
4,355,909 | 2010-12-04T21:24:00.000 | 4 | 0 | 0 | 0 | python,mysql,ruby-on-rails,nosql | 4,355,976 | 3 | true | 1 | 0 | I don't think "NoSQL" has anything to do with "no model".
For one, MVC originated in the Smalltalk world for desktop applications, long before the current web server architecture (or even the web itself) existed. Most apps I've written have used MVC (including the M), even those that didn't use a DBMS (R or otherwise).
For another, some kinds of "NoSQL" explicitly have a model. An object database might look, to the application code, almost just like the interface that your "SQL RDBMS + ORM" are trying to expose, but without all the weird quirks and explicit mapping and so on.
Finally, you can obviously go the other way, and write SQL-based apps with no model. It may not be pretty, but I've seen it done. | 3 | 0 | 0 | With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql?
Note
I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar. | With the rise of NoSQL, Is it more common these days to have a webapp without any model? | 1.2 | 1 | 0 | 210 |
4,356,234 | 2010-12-04T22:43:00.000 | 1 | 0 | 0 | 1 | python,django,user-interface,login | 4,361,550 | 2 | false | 1 | 0 | Django auth also provide generic views for login/logout etc. You can use build-in templates or expand it.
See in documentation for generic views: django.contrib.auth.views.login, django.contrib.auth.views.logout | 1 | 0 | 0 | i love gae(google app engine),because it is easy to create a user interface for user login and signup,
but now , my boss want me to create a site use django ,
so the first is to create a site that someone can be login ,
which is the esaist way to create a user interface ?
thanks | how to create a user interface that a user can signup and login using django | 0.099668 | 0 | 0 | 888 |
4,356,293 | 2010-12-04T22:56:00.000 | 1 | 0 | 1 | 1 | python,shared-libraries,compiled | 5,087,086 | 2 | true | 0 | 0 | bbfreeze will put everything in a single executable. | 1 | 3 | 0 | I am using cx_freeze to compile my python script and when I compile the program, all the files are placed in one specified folder. The executable wont run if the shared libs are not within the same directory.
How would I set it up so the executable looks within /usr/lib/PROGRAMNAME/ to run the libraries? | Cx_freeze - How can I Install the shared libraries to /usr/lib | 1.2 | 0 | 0 | 700 |
4,356,776 | 2010-12-05T00:56:00.000 | 9 | 1 | 0 | 0 | python,google-app-engine,email | 4,356,783 | 1 | true | 1 | 0 | Put a hash in the URL that uniquely identifies the address you sent it to. | 1 | 2 | 0 | I am working with Google App Engine python version. The app sends an
email to the user with a link to a page to upload an image as an
avatar. It would be nice to have the email so that I can associate the
avatar with that email. How can I get the email of the person who just clicked the link? Thank you. | How do I get the email address of the person who clicked the link in the email? | 1.2 | 0 | 0 | 1,324 |
4,357,176 | 2010-12-05T03:16:00.000 | 6 | 0 | 0 | 0 | c#,asp.net,python,django | 4,357,364 | 3 | true | 1 | 0 | I've been an ASP.NET programmer for a few years, and I think it's pretty easy to get into. The downsides here are that Microsoft products (TFS in particular) are expensive. Of course, my experiences have been directly related to that -- I've never tried Python in any regard -- so I can only offer my perspectives as an ASP.NET programmer.
There are a lot of people who would (accurately) tell you that the page lifecycle in ASP.NET is a gigantic pain in the ass, and that's true too. I personally don't use the server-side part of ASP.NET very often anymore because juggling the lifecycle just leads to messy code and built-in obtuseness. That said, it's really easy to integrate ASP.NET WebServices with jQuery and JavaScript.
My experiences with IIS have been pretty good as well, although I can't speak to its problems in more complex environments.
I do love TFS, though. In particular, if you're working as a part of a team and need to get user bug reports or enhancement requests, there's a lot of great built-in integration. However, configuring and maintaining TFS is a full-time job in and of itself if you're a part of a development team in a corporation.
All that said, I'm not sure it makes much sense to limit yourself to two core languages and then ask about career opportunities. These are going to vary from place to place. I don't see many Python positions where I live, and there were a lot of MS/C#/ASP.NET positions available when I was looking for a job. | 2 | 5 | 0 | Hello I am interested in hearing objective responses in what should a beginner dedicate his or her time into:
ASP.NET, Visual Studio, C#, IIS, Team Foundation Server?
or
Python, Django, PyCharm?
These are just some criteria that I am interested in:
Easy to start out with.
Good documentation.
Highly-scalable.
Big Career opportunities.
Feel free to post your personal opinion on this matter or if you've had an experience with both ASP.NET and Django. | New to web development. ASP.NET or Django? | 1.2 | 0 | 0 | 12,666 |
4,357,176 | 2010-12-05T03:16:00.000 | 16 | 0 | 0 | 0 | c#,asp.net,python,django | 4,357,372 | 3 | false | 1 | 0 | C# or java will pay the bills, python will be way more fun | 2 | 5 | 0 | Hello I am interested in hearing objective responses in what should a beginner dedicate his or her time into:
ASP.NET, Visual Studio, C#, IIS, Team Foundation Server?
or
Python, Django, PyCharm?
These are just some criteria that I am interested in:
Easy to start out with.
Good documentation.
Highly-scalable.
Big Career opportunities.
Feel free to post your personal opinion on this matter or if you've had an experience with both ASP.NET and Django. | New to web development. ASP.NET or Django? | 1 | 0 | 0 | 12,666 |
4,357,841 | 2010-12-05T07:35:00.000 | 4 | 0 | 1 | 0 | python | 4,357,850 | 3 | false | 0 | 0 | Use zip: [x + y for x, y in zip(list1, list2)]. | 1 | 0 | 0 | I have 2 lists :
list1 contains "T" "F" "T" "T"
list2 contains "a" "b" "c" "d"
I want to create a third list such that I append element1 in list1 to element1 in list2.
So list3 would be the following: "Ta" "Fb" "Tc" "Td"
How can i do that? | appending a string to another string | 0.26052 | 0 | 0 | 135 |
4,358,179 | 2010-12-05T09:35:00.000 | 1 | 0 | 1 | 0 | python,ide,enthought | 4,358,228 | 2 | true | 0 | 0 | Any reason why such an IDE does not
make sense?
Most people who use Python don't use the Enthought tool suite, so there's not enough interest to create a project (or demand for a company to sell a product).
I know that's not what you want to hear, so here's a few options:
Find a bunch of smart people who also like it and would like an IDE built with Enthought and build an IDE
Clamor for Enthought to make an IDE
You can always use Eclipse or another open-source IDE as a backend and just build a new UI. | 1 | 0 | 0 | Has anybody come across an Enthought TraitsUI (Envisage etc) based Python IDE?
I wonder why there is none, when Enthought Tool Suite makes it so easy to create extensible python GUI applications.
One reason I can think of, why such an IDE makes a lot of sense, is because it will be cross platform.
Any reason why such an IDE does not make sense? | Enthought TraitsUI based Python IDE | 1.2 | 0 | 0 | 717 |
4,358,701 | 2010-12-05T12:12:00.000 | 0 | 0 | 1 | 0 | python | 4,358,722 | 5 | false | 0 | 0 | Use glob to find the filenames, slice the strings, and use os.rename() to rename them. | 1 | 5 | 0 | I wanted to know what is the easiest way to rename multiple files using re module in python if at all it is possible.
In my directory their are 25 files all with the file names in the format ' A unique name followed by 20 same characters.mkv '
What I wanted was to delete all the 20 characters.
How can I do this using Python if at all it is possible :) | Renaming multiple files in python | 0 | 0 | 0 | 9,424 |
4,360,407 | 2010-12-05T18:24:00.000 | 1 | 0 | 0 | 0 | python,sqlite | 4,360,475 | 2 | true | 1 | 0 | I could be wrong, but I think there is no definite answer to this question. It depends on "language" level your framework provides. For example, if another parts of the framework accept data in non-canonical form and then convert it to an internal canonical form, it this case it would worth to support some input date formats that are expected.
I always prefer to build strict frameworks and convert data in front-ends. | 2 | 0 | 0 | When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/yyyy' format needs to be converted to a Python date-object or 'yyyy-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yyyy', but that can cause problems when data is retrieved).
Question - at what point should the data be converted?
a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called).
b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command).
In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing?
Any opinions would be appreciated.
Alan | Framework design question | 1.2 | 1 | 0 | 75 |
4,360,407 | 2010-12-05T18:24:00.000 | 2 | 0 | 0 | 0 | python,sqlite | 4,360,452 | 2 | false | 1 | 0 | I think it belongs in the validation. You want a date, but the web page inputs strings only, so the validator needs to check if the value van be converted to a date, and from that point on your application should process it like a date. | 2 | 0 | 0 | When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/yyyy' format needs to be converted to a Python date-object or 'yyyy-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yyyy', but that can cause problems when data is retrieved).
Question - at what point should the data be converted?
a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called).
b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command).
In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing?
Any opinions would be appreciated.
Alan | Framework design question | 0.197375 | 1 | 0 | 75 |
4,362,721 | 2010-12-06T02:37:00.000 | 5 | 0 | 0 | 0 | python,http | 4,362,770 | 1 | true | 0 | 0 | Assuming that the server is sending the response body size in the Content-Length response header field, you can do it yourself.
First, call Http.request(method="HEAD") to retrieve only the headers and not the body. Then inspect the Content-Length field of the response to see if it is below your threshold. If it is, make a second request with the proper GET or POST method to retrieve the body; otherwise produce an error.
If the server isn't giving you the Content-Length (or is lying about it), it doesn't look like there is a way to cut off the download after some number of bytes. | 1 | 4 | 0 | Is it possible to limit the response size with httplib2? For instance if it sees an HTTP body over X bytes the connection will just close without consuming more bandwidth. Or perhaps only download the first X bytes of a file. | Limiting response size with httplib2 | 1.2 | 0 | 1 | 720 |
4,362,902 | 2010-12-06T03:20:00.000 | 2 | 0 | 1 | 0 | python,django,django-templates | 4,366,241 | 4 | false | 1 | 0 | Don't forget that you aren't limited to Django's template language. You're free to use whatever templating system you like in your view functions. However you want to create the HTML to return from your view function is fine. There are many templating implementations in the Python world: choose one that suits you better, and use it. | 3 | 9 | 0 | I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going.
Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for? | Why don't django templates just use python code? | 0.099668 | 0 | 0 | 594 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.