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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
550,804 | 2009-02-15T12:29:00.000 | 2 | 0 | 0 | 0 | python,error-handling,pycurl | 550,815 | 3 | false | 0 | 0 | Can you catch all exceptions somewhere in the main block and use sys.exc_info() for callback information and log that to your file. exc_info() returns not just exception type, but also call traceback so there should information what went wrong. | 1 | 2 | 0 | I am using libcurl to DL a webpage, then i am scanning it for data and doing something with one of the links. However, once in a while the page is different then i except thus i extract bad data and pycurl throws an exception. I tried finding the exception name for pycurl but had no luck.
Is there a way i can get the t... | python runtime error, can dump a file? | 0.132549 | 0 | 1 | 992 |
551,038 | 2009-02-15T15:29:00.000 | 11 | 0 | 1 | 0 | python,access-modifiers | 551,047 | 7 | false | 0 | 0 | The convention is prepend "_" to internal classes, functions, and variables. | 1 | 139 | 0 | I am coding a small Python module composed of two parts:
some functions defining a public interface,
an implementation class used by the above functions, but which is not meaningful outside the module.
At first, I decided to "hide" this implementation class by defining it inside the function using it, but this hamper... | "Private" (implementation) class in Python | 1 | 0 | 0 | 118,992 |
551,227 | 2009-02-15T17:12:00.000 | 5 | 1 | 1 | 0 | c++,python,deployment,scripting-language,embedded-language | 551,332 | 4 | false | 0 | 0 | To extend the answer by gimel, there is nothing to stop you from shipping python.dll, using it, and setting a correct PYTHONPATH in order to use your own installation of the python standard library. They are just libraries and files, and your install process can just deal with them as such. | 1 | 18 | 0 | I'm thinking about using Python as an embedded scripting language in a hobby project written in C++. I would not like to depend on separately installed Python distribution. Python documentation seems to be quite clear about general usage, but I couldn't find a clear answer to this.
Is it feasible to deploy a Python int... | Deploying application with Python or another embedded scripting language | 0.244919 | 0 | 0 | 4,914 |
551,465 | 2009-02-15T19:45:00.000 | 16 | 1 | 1 | 0 | python,ruby-on-rails,ruby,comparison | 552,734 | 8 | true | 1 | 0 | Both languages are powerful and fun. Either would be a useful addition to your tool box.
Python has a larger community and probably more mature documentation and libraries. Its object-orientation is a little inconsistent and feels (to me, IMHO) like something that was bolted on to the language. You can alter class beha... | 5 | 12 | 0 | I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ru... | Python or Ruby for a .NET developer? | 1.2 | 0 | 0 | 1,835 |
551,465 | 2009-02-15T19:45:00.000 | 6 | 1 | 1 | 0 | python,ruby-on-rails,ruby,comparison | 551,484 | 8 | false | 1 | 0 | First... good for you for wanting to broaden your knowledge! Second, you are comparing a language (Python) with a web framework (Ruby on Rails).
I think your best option is to try a few different frameworks in both Python and Ruby, do the same fairly simple task in each, and only then pick which one you'd like to learn... | 5 | 12 | 0 | I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ru... | Python or Ruby for a .NET developer? | 1 | 0 | 0 | 1,835 |
551,465 | 2009-02-15T19:45:00.000 | 2 | 1 | 1 | 0 | python,ruby-on-rails,ruby,comparison | 552,177 | 8 | false | 1 | 0 | Rule of thumb - Python if you like strict rules and Ruby if you hate them.
Another one: if you adore JavaScript - Ruby is your choice :) | 5 | 12 | 0 | I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ru... | Python or Ruby for a .NET developer? | 0.049958 | 0 | 0 | 1,835 |
551,465 | 2009-02-15T19:45:00.000 | 2 | 1 | 1 | 0 | python,ruby-on-rails,ruby,comparison | 555,166 | 8 | false | 1 | 0 | What? No mention of IronPython?
IronPython is the flagship language of the DLR. It allows you to use all the familiar .NET libraries, but through Python.
I would definitely try Python and IronPython. You'll learn a lot and might even sneak it into your current projects (you can embed an IronPython engine in a .NET appl... | 5 | 12 | 0 | I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ru... | Python or Ruby for a .NET developer? | 0.049958 | 0 | 0 | 1,835 |
551,465 | 2009-02-15T19:45:00.000 | 0 | 1 | 1 | 0 | python,ruby-on-rails,ruby,comparison | 552,126 | 8 | false | 1 | 0 | I'd get in on Ruby. Seems to have a larger (or at least more active) community, the pace of new projects & continued development is second-to-none, and the learning resources seem to outnumber & outpace those of Python. I could be wrong, but these are my impressions. | 5 | 12 | 0 | I'm a C# .NET developer and I work on mostly ASP.NET projects.
I want to learn a new programming language,
to improve my programming skills by experiencing a new language,
to see something different then microsoft environment,
and maybe to think in a different way.
I focus on two languages for my goal. Python and Ru... | Python or Ruby for a .NET developer? | 0 | 0 | 0 | 1,835 |
552,329 | 2009-02-16T05:26:00.000 | 0 | 0 | 1 | 0 | python | 552,432 | 4 | false | 0 | 0 | when you load the module, python executes each of the code line by line. Since code is executed, class variables should all be set at load time. Most likely your boto.config.get function was just returned None. In another word, yes, all class variables are allocated before instance variables. | 2 | 4 | 0 | I have a code file from the boto framework pasted below, all of the print statements are mine, and the one commented out line is also mine, all else belongs to the attributed author.
My question is what is the order in which instantiations and allocations occur in python when instantiating a class? The author's code b... | How do python classes work? | 0 | 0 | 0 | 2,377 |
552,329 | 2009-02-16T05:26:00.000 | 1 | 0 | 1 | 0 | python | 552,482 | 4 | false | 0 | 0 | Thank you all for your help. I figured out what I was missing:
The class definitions of the boto classes I am using contain class variables for Manager, which in turn serve as a default value if no Manager is passed to the __init__() of these classes. I didn't even think about the fact that these class variables would... | 2 | 4 | 0 | I have a code file from the boto framework pasted below, all of the print statements are mine, and the one commented out line is also mine, all else belongs to the attributed author.
My question is what is the order in which instantiations and allocations occur in python when instantiating a class? The author's code b... | How do python classes work? | 0.049958 | 0 | 0 | 2,377 |
555,146 | 2009-02-17T00:29:00.000 | 2 | 0 | 0 | 0 | python,file-io | 555,159 | 2 | false | 0 | 0 | I would open seven file streams as accumulating them might be quite memory extensive if it's a lot of data. Of course that is only an option if you can sort them live and don't first need all data read to do the sorting. | 1 | 0 | 1 | edit: Initially I was trying to be general but it came out vague. I've included more detail below.
I'm writing a script that pulls in data from two large CSV files, one of people's schedules and the other of information about their schedules. The data is mined and combined to eventually create pajek format graphs for ... | Multiple output files | 0.197375 | 0 | 0 | 593 |
556,730 | 2009-02-17T13:16:00.000 | 1 | 1 | 0 | 0 | python,serialization,caching | 556,961 | 6 | false | 0 | 0 | cPickle will be the fastest since it is saved in binary and no real python code has to be parsed.
Other advantates are that it is more secure (since it does not execute commands) and you have no problems with setting $PYTHONPATH correctly. | 1 | 11 | 1 | I need to load (de-serialize) a pre-computed list of integers from a file in a Python script (into a Python list). The list is large (upto millions of items), and I can choose the format I store it in, as long as loading is fastest.
Which is the fastest method, and why?
Using import on a .py file that just contains th... | Python list serialization - fastest method | 0.033321 | 0 | 0 | 8,359 |
556,907 | 2009-02-17T13:58:00.000 | 8 | 0 | 0 | 0 | python,django,deployment,session,cookies | 659,606 | 2 | false | 1 | 0 | I agree that sharing sessions between Django instances is probably not a good idea. If you really wanted to, you could:
make sure the two django applications share the same SECRET_KEY
make sure the two django applications share the same SeSSON_COOKIE_NAME
make sure the SESSION_COOKIE_DOMAIN is set to something that le... | 2 | 8 | 0 | We have a couple of Django applications deployed on the same subdomain. A few power users need to jump between these applications. I noticed that each time they bounce between applications their session cookie receives a new session ID from Django.
I don't use the Django session table much except in one complex wor... | How to get distinct Django apps on same subdomain to share session cookie? | 1 | 0 | 0 | 6,592 |
556,907 | 2009-02-17T13:58:00.000 | 18 | 0 | 0 | 0 | python,django,deployment,session,cookies | 557,020 | 2 | true | 1 | 0 | I would instead advise you to set SESSION_COOKIE_NAME to different values for the two apps. Your users will still have to log in twice initially, but their sessions won't conflict - if they log in to app A, then app B, and return to A, they'll still have their A session.
Sharing sessions between Django instances is pro... | 2 | 8 | 0 | We have a couple of Django applications deployed on the same subdomain. A few power users need to jump between these applications. I noticed that each time they bounce between applications their session cookie receives a new session ID from Django.
I don't use the Django session table much except in one complex wor... | How to get distinct Django apps on same subdomain to share session cookie? | 1.2 | 0 | 0 | 6,592 |
557,171 | 2009-02-17T14:50:00.000 | 2 | 0 | 0 | 0 | python,django,code-reuse | 3,710,136 | 2 | false | 1 | 0 | An old question, but here's what I do:
If you're using a version control system (VCS), I suggest putting all of the reusable apps and libraries (including django) that your software needs in the VCS. If you don't want to put them directly under your project root, you can modify settings.py to add their location to sys.... | 1 | 22 | 0 | I am trying to create my first site in Django and as I'm looking for example apps out there to draw inspiration from, I constantly stumble upon a term called "reusable apps".
I understand the concept of an app that is reusable easy enough, but the means of reusing an app in Django are quite lost for me. Few questions ... | How to re-use a reusable app in Django | 0.197375 | 0 | 0 | 3,945 |
557,199 | 2009-02-17T14:56:00.000 | 1 | 0 | 0 | 0 | python,object | 558,822 | 8 | false | 0 | 0 | Here are a couple points for you to consider. If your data is large reading it all into memory may be wasteful. If you need random access and not just sequential access to your data then you'll either have to scan the at most the entire file each time or read that table into an indexed memory structure like a diction... | 5 | 0 | 0 | I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat... | Converting a database-driven (non-OO) python script into a non-database driven, OO-script | 0.024995 | 1 | 0 | 330 |
557,199 | 2009-02-17T14:56:00.000 | 5 | 0 | 0 | 0 | python,object | 557,473 | 8 | true | 0 | 0 | If the data is a natural fit for database tables ("rectangular data"), why not convert it to sqlite? It's portable -- just one file to move the db around, and sqlite is available anywhere you have python (2.5 and above anyway). | 5 | 0 | 0 | I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat... | Converting a database-driven (non-OO) python script into a non-database driven, OO-script | 1.2 | 1 | 0 | 330 |
557,199 | 2009-02-17T14:56:00.000 | 1 | 0 | 0 | 0 | python,object | 557,279 | 8 | false | 0 | 0 | you could have a fruit class with id and name instance variables. and a function to read/write the information from a file, and maybe a class variable to keep track of the number of fruits (objects) created | 5 | 0 | 0 | I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat... | Converting a database-driven (non-OO) python script into a non-database driven, OO-script | 0.024995 | 1 | 0 | 330 |
557,199 | 2009-02-17T14:56:00.000 | 1 | 0 | 0 | 0 | python,object | 557,241 | 8 | false | 0 | 0 | There's no "one size fits all" answer for this -- it'll depend a lot on the data and how it's used in the application. If the data and usage are simple enough you might want to store your fruit in a dict with id as key and the rest of the data as tuples. Or not. It totally depends. If there's a guiding principle out th... | 5 | 0 | 0 | I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat... | Converting a database-driven (non-OO) python script into a non-database driven, OO-script | 0.024995 | 1 | 0 | 330 |
557,199 | 2009-02-17T14:56:00.000 | 2 | 0 | 0 | 0 | python,object | 557,291 | 8 | false | 0 | 0 | Generally you want your Objects to absolutely match your "real world entities".
Since you're starting from a database, it's not always the case that the database has any real-world fidelity, either. Some database designs are simply awful.
If your database has reasonable models for Fruit, that's where you start. Get t... | 5 | 0 | 0 | I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat... | Converting a database-driven (non-OO) python script into a non-database driven, OO-script | 0.049958 | 1 | 0 | 330 |
557,555 | 2009-02-17T16:10:00.000 | 1 | 0 | 0 | 0 | python,emacs | 557,779 | 5 | false | 0 | 0 | You might want to customize the pop-up-windows variable; that controls the splitting functionality. | 2 | 6 | 0 | In python-mode (for emacs), hitting Control-C\Control-C will execute the current buffer. However, when execution is finished, the output buffer springs up and splits my editing window in half. This is a complete pain, especially given that there's generally no output in the buffer anyway!
Is there a way to stop the b... | How do I suppress python-mode's output buffer? | 0.039979 | 0 | 0 | 2,030 |
557,555 | 2009-02-17T16:10:00.000 | 0 | 0 | 0 | 0 | python,emacs | 557,820 | 5 | false | 0 | 0 | Don't know how to stop it from popping up, but C-x, 1 will close the window. | 2 | 6 | 0 | In python-mode (for emacs), hitting Control-C\Control-C will execute the current buffer. However, when execution is finished, the output buffer springs up and splits my editing window in half. This is a complete pain, especially given that there's generally no output in the buffer anyway!
Is there a way to stop the b... | How do I suppress python-mode's output buffer? | 0 | 0 | 0 | 2,030 |
558,776 | 2009-02-17T21:20:00.000 | 2 | 0 | 0 | 1 | python,windows | 558,808 | 5 | false | 0 | 0 | Good question. One thing you could do is create a shortcut to the script in Windows, and pass arguments (using the shortcut's Target property) that would denote the script was launched by double-clicking (in this case, a shortcut). | 2 | 8 | 0 | Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows? | Detect script start up from command prompt or "double click" on Windows | 0.07983 | 0 | 0 | 3,077 |
558,776 | 2009-02-17T21:20:00.000 | 3 | 0 | 0 | 1 | python,windows | 558,804 | 5 | false | 0 | 0 | The command-prompt started script has a parent process named cmd.exe (or a non-existent process, in case the console has been closed in the mean time).
The doubleclick-started script should have a parent process named explorer.exe. | 2 | 8 | 0 | Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows? | Detect script start up from command prompt or "double click" on Windows | 0.119427 | 0 | 0 | 3,077 |
558,999 | 2009-02-17T22:25:00.000 | 5 | 0 | 0 | 0 | python,django,eclipse,pydev | 561,957 | 4 | true | 1 | 0 | Have you imported the Django source as a project? To do that you just create a new PyDev project and set it's location to the Django source folder. | 2 | 5 | 0 | I am debugging a problem in Django with Pydev.
I can set breakpoint in my django project code with out a problem.
However I can't set breakpoints in the Django library source code (in site-packages).
The PyDev debugger user interface in this case simply does nothing when I click to set the breakpoint and does not bre... | Eclipse PyDev: setting breakpoints in site-packages source | 1.2 | 0 | 0 | 4,282 |
558,999 | 2009-02-17T22:25:00.000 | 0 | 0 | 0 | 0 | python,django,eclipse,pydev | 2,516,750 | 4 | false | 1 | 0 | PyDev 1.5.5 seems to have an issue with Eclipse. Uninstall 1.5.5 and install the 1.5.4 version | 2 | 5 | 0 | I am debugging a problem in Django with Pydev.
I can set breakpoint in my django project code with out a problem.
However I can't set breakpoints in the Django library source code (in site-packages).
The PyDev debugger user interface in this case simply does nothing when I click to set the breakpoint and does not bre... | Eclipse PyDev: setting breakpoints in site-packages source | 0 | 0 | 0 | 4,282 |
559,096 | 2009-02-17T22:53:00.000 | 0 | 0 | 0 | 0 | python,file,pdf | 584,225 | 7 | false | 1 | 0 | By valid do you mean that it can be displayed by a PDF viewer, or that the text can be extracted? They are two very different things.
If you just want to check that it really is a PDF file that has been uploaded then the pyPDF solution, or something similar, will work.
If, however, you want to check that the text can ... | 1 | 22 | 0 | I get a File via a HTTP-Upload and need to be sure its a pdf-file. Programing Language is Python, but this should not matter.
I thought of the following solutions:
Check if the first bytes of the string are "%PDF". This is not a good check but prevents the use from uploading other files accidentally.
Try the libmagic... | Check whether a PDF-File is valid with Python | 0 | 0 | 0 | 32,854 |
561,301 | 2009-02-18T14:38:00.000 | 1 | 0 | 0 | 0 | python,chat | 564,419 | 3 | false | 0 | 0 | Honestly, I think it'd be best for you to roll your own and get it tightly integrated with your program. I know there's no sense in reinventing the wheel, but there are several advantages to doing so in your case: integration, learning, security, and simplicity. | 1 | 3 | 0 | I'm making a game and I am using Python for the server side.
It would be fairly trivial to implement chat myself using Python - that's not my question.
My question is
I was just wondering if there were any pre-made chat servers or some kind of service that I would be able to implement inside of my game instead of rol... | Implementing chat in an application? | 0.066568 | 0 | 0 | 993 |
561,486 | 2009-02-18T15:25:00.000 | 4 | 0 | 0 | 0 | python,url,base64 | 561,534 | 15 | false | 0 | 0 | Base64 takes 4 bytes/characters to encode 3 bytes and can only encode multiples of 3 bytes (and adds padding otherwise).
So representing 4 bytes (your average int) in Base64 would take 8 bytes. Encoding the same 4 bytes in hex would also take 8 bytes. So you wouldn't gain anything for a single int. | 2 | 68 | 0 | I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the ... | How to convert an integer to the shortest url-safe string in Python? | 0.053283 | 0 | 1 | 34,136 |
561,486 | 2009-02-18T15:25:00.000 | 2 | 0 | 0 | 0 | python,url,base64 | 561,547 | 15 | false | 0 | 0 | If you are looking for a way to shorten the integer representation using base64, I think you need to look elsewhere. When you encode something with base64 it doesn't get shorter, in fact it gets longer.
E.g. 11234 encoded with base64 would yield MTEyMzQ=
When using base64 you have overlooked the fact that you are not ... | 2 | 68 | 0 | I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the ... | How to convert an integer to the shortest url-safe string in Python? | 0.02666 | 0 | 1 | 34,136 |
562,519 | 2009-02-18T19:38:00.000 | 1 | 0 | 1 | 0 | python,python-imaging-library | 562,533 | 2 | false | 0 | 0 | Image.save(filename[, format[, options]]). You can usually just use Image.save(filename) since it automatically figures out the file type for you from the extension. | 1 | 13 | 0 | Simple one I think but essentially I need to know what the syntax is for the save function on the PIL. The help is really vague and I can't find anything online. Any help'd be great, thanks :). | Python Imaging Library save function syntax | 0.099668 | 0 | 0 | 32,920 |
564,460 | 2009-02-19T09:01:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,storage,cloud,mosso | 564,966 | 1 | true | 1 | 0 | It appears to implement a simple RESTful API, so there's no reason you couldn't use it from App Engine. Previously, you'd have had to write your own library to do so, using App Engine's urlfetch API, but with the release of SDK 1.1.9, you can now use urllib and httplib instead. | 1 | 1 | 0 | I'm wondering if anybody tried to integrate mosso CloudFiles with an application running on Google AppEngine (mosso does not provide testing sandbox so I cann't check for myself without registering)? Looking at the code it seems that this will not work due to httplib and urllib limitations in AppEngine environment, but... | Anybody tried mosso CloudFiles with Google AppEngine? | 1.2 | 0 | 0 | 310 |
564,469 | 2009-02-19T09:05:00.000 | 0 | 1 | 0 | 0 | java,c++,python | 1,949,983 | 14 | false | 0 | 1 | There is a RPG engine called VERGE if you're interested. Never tried it but I heard good things from it.
I think it's in C++. | 1 | 9 | 0 | For C++, Java, or Python, what are some good game + free game engines that are easy to pick up?
Any type of game engine is okay. I just want to get started somewhere by looking into different game engines and their capabilities. | What is a good & free game engine? | 0 | 0 | 0 | 10,754 |
565,030 | 2009-02-19T12:14:00.000 | 3 | 0 | 1 | 0 | python,64-bit | 565,041 | 2 | false | 0 | 0 | The language python itself has no such restrictions, but perhaps your operating system or your python runtime (pypy, cpython, jython) could have such restrictions.
What combination of python runtime and OS do you want to use? | 2 | 6 | 0 | if I run python on a 64bit machine with a 64bit operating system, will my programs be able to access the full range of memory? I.e. Could I build a list with 10billion entries, assuming I had enough RAM? If not, are there other programming languages that would allow this? | can my programs access more than 4GB of memory? | 0.291313 | 0 | 0 | 1,173 |
565,030 | 2009-02-19T12:14:00.000 | 7 | 0 | 1 | 0 | python,64-bit | 565,085 | 2 | true | 0 | 0 | You'll need to be sure that Python has been built as a 64 bit application. For example, on Win64 you'll be able to run the 32bit build of Python.exe but it won't get the benefits of the 64 bit environment as Windows will run it in a 32bit sandbox. | 2 | 6 | 0 | if I run python on a 64bit machine with a 64bit operating system, will my programs be able to access the full range of memory? I.e. Could I build a list with 10billion entries, assuming I had enough RAM? If not, are there other programming languages that would allow this? | can my programs access more than 4GB of memory? | 1.2 | 0 | 0 | 1,173 |
565,264 | 2009-02-19T13:19:00.000 | 0 | 0 | 0 | 0 | c#,.net,python,html | 568,228 | 3 | false | 1 | 0 | Just found HTML agility pack to be useful enough, as they understand C# better than python. | 2 | 0 | 0 | One of my friends is working on having a good solution to generate aspx pages, out of html pages generated from a legacy asp application.
The idea is to run the legacy app, capture html output, clean the html using some tool (say HtmlTidy) and parse it/transform it to aspx, (using Xslt or a custom tool) so that existi... | Parsing HTML generated from Legacy ASP Application to create ASP.NET 2.0 Pages | 0 | 0 | 0 | 307 |
565,264 | 2009-02-19T13:19:00.000 | 0 | 0 | 0 | 0 | c#,.net,python,html | 1,664,516 | 3 | false | 1 | 0 | I know this is an old question, but in a similar situation (50k+ legacy ASP pages that need to display in a .NET framework), I did the following.
Created a rewrite engine (HttpModule) which catches all incoming requests and looks for anything that is from the old site.
(in a separate class - keep things organized!) us... | 2 | 0 | 0 | One of my friends is working on having a good solution to generate aspx pages, out of html pages generated from a legacy asp application.
The idea is to run the legacy app, capture html output, clean the html using some tool (say HtmlTidy) and parse it/transform it to aspx, (using Xslt or a custom tool) so that existi... | Parsing HTML generated from Legacy ASP Application to create ASP.NET 2.0 Pages | 0 | 0 | 0 | 307 |
566,865 | 2009-02-19T19:50:00.000 | 4 | 1 | 1 | 0 | python | 4,105,859 | 16 | false | 0 | 0 | Think like this:
If you are writing too much for little work, something is wrong, this is not pythonic.
Most Python code you will write is very simple and direct. Usually you don't need much work for anything simple. If you are writing too much, stop and think if there is a better way. (and this is how I learned many... | 5 | 16 | 0 | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Python: Am I missing something? | 0.049958 | 0 | 0 | 3,078 |
566,865 | 2009-02-19T19:50:00.000 | 2 | 1 | 1 | 0 | python | 689,204 | 16 | false | 0 | 0 | Write some Python code and post it on SO for review and feedback whether it is pythonic. | 5 | 16 | 0 | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Python: Am I missing something? | 0.024995 | 0 | 0 | 3,078 |
566,865 | 2009-02-19T19:50:00.000 | 0 | 1 | 1 | 0 | python | 571,297 | 16 | false | 0 | 0 | To echo TLHOLADAY, read the standard library. That's where the "pythonic" stuff is. If you're not getting a good feel there, then read the source for sqlachemy or django or your project of choice. | 5 | 16 | 0 | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Python: Am I missing something? | 0 | 0 | 0 | 3,078 |
566,865 | 2009-02-19T19:50:00.000 | 0 | 1 | 1 | 0 | python | 569,123 | 16 | false | 0 | 0 | I would suggest finding a personal python guru. Show them some of your code and have them review/rewrite it into idiomatic python. Thus will you be enlightened. | 5 | 16 | 0 | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Python: Am I missing something? | 0 | 0 | 0 | 3,078 |
566,865 | 2009-02-19T19:50:00.000 | 3 | 1 | 1 | 0 | python | 566,934 | 16 | false | 0 | 0 | To add to the answers of Andrew Hare and Baishampayan Ghose...
To learn the idiom of any language must involve reading code written in that idiom. I'm still learning the Python idiom, but I've been through this with other languages. I can read about list comprehensions, but the lightbulb only really comes on when you s... | 5 | 16 | 0 | I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I keep having the feeling I'm missing something, such as "The Python Way". I know build scripts and glue scripts are not really the most excitin... | Python: Am I missing something? | 0.037482 | 0 | 0 | 3,078 |
567,324 | 2009-02-19T21:47:00.000 | 9 | 0 | 0 | 0 | python,url,uuid | 567,347 | 3 | false | 0 | 0 | It is good practice to always urlencode data that will be placed into URLs. Then you need not be concerned with the specifics of UUID or if it will change in the future. | 1 | 4 | 0 | Is it safe to use Python UUID module generated values in URL's of a webpage? Wnat to use those ID's as part of URL's. Are there any non-safe characters ever generated by Python UUID that shouldn't be in URL's? | Is it safe to use Python UUID module generated values in URL's of a webpage? | 1 | 0 | 1 | 3,987 |
567,999 | 2009-02-20T01:52:00.000 | 4 | 0 | 0 | 0 | python,xml,beautifulsoup | 568,081 | 2 | true | 1 | 0 | No, that's not a built-in option. The source is pretty straightforward, though. It looks like you want to change the value of encodedName in Tag.__str__. | 1 | 10 | 0 | I am using BeautifulStoneSoup to parse an XML document and change some attributes. I noticed that it automatically converts all XML tags to lowercase. For example, my source file has <DocData> elements, which BeautifulSoup converts to <docdata>.
This appears to be causing problems since the program I am feeding my modi... | Preventing BeautifulSoup from converting my XML tags to lowercase | 1.2 | 0 | 1 | 1,662 |
568,271 | 2009-02-20T04:22:00.000 | -2 | 0 | 0 | 1 | python,process,pid | 568,614 | 14 | false | 0 | 0 | I'd say use the PID for whatever purpose you're obtaining it and handle the errors gracefully. Otherwise, it's a classic race (the PID may be valid when you check it's valid, but go away an instant later) | 1 | 127 | 0 | Is there a way to check to see if a pid corresponds to a valid process? I'm getting a pid from a different source other than from os.getpid() and I need to check to see if a process with that pid doesn't exist on the machine.
I need it to be available in Unix and Windows. I'm also checking to see if the PID is NOT in ... | How to check if there exists a process with a given pid in Python? | -0.028564 | 0 | 0 | 136,481 |
569,321 | 2009-02-20T11:54:00.000 | 4 | 0 | 1 | 0 | python,audio,midi | 884,375 | 7 | false | 0 | 0 | Midi support (in and out) has been added to pyGame 1.9, though it's mainly in the development stage and isn't very well documented yet, but it works.
Midi support is also being developed in the pyGame successor, pgreloaded (or pygame2).
Also note that even though pyGame has 'game' in the title, its uses stretch far bey... | 1 | 28 | 0 | I want to do build a small app that creates MIDI sounds. I've never dealt with sound in programming so I'd like to start with something that's basic and has good documentation. I want to stick with Python since I'm the most comfortable with it and don't want to overwhelm myself, initially.
My time is split about 50/50 ... | Simple, Cross Platform MIDI Library for Python | 0.113791 | 0 | 0 | 25,392 |
569,468 | 2009-02-20T12:50:00.000 | 3 | 0 | 0 | 0 | python,django,django-forms | 569,763 | 7 | false | 1 | 0 | "I want to hide some of the fields and do some complex validation."
I start with the built-in admin interface.
Build the ModelForm to show the desired fields.
Extend the Form with the validation rules within the form. Usually this is a clean method.
Be sure this part works reasonably well.
Once this is done, you can... | 1 | 124 | 0 | I'm building a support ticket tracking app and have a few models I'd like to create from one page. Tickets belong to a Customer via a ForeignKey. Notes belong to Tickets via a ForeignKey as well. I'd like to have the option of selecting a Customer (that's a whole separate project) OR creating a new Customer, then creat... | Django: multiple models in one template using forms | 0.085505 | 0 | 0 | 119,625 |
570,137 | 2009-02-20T16:04:00.000 | 1 | 0 | 0 | 0 | python,numpy | 570,197 | 4 | false | 0 | 0 | In addition to df's answer, if you want to know the specific prices that are above the base prices, you can do:
prices[prices > (1.10 * base_prices)] | 1 | 1 | 1 | I am working at some plots and statistics for work and I am not sure how I can do some statistics using numpy: I have a list of prices and another one of basePrices. And I want to know how many prices are with X percent above basePrice, how many are with Y percent above basePrice.
Is there a simple way to do that using... | Statistics with numpy | 0.049958 | 0 | 0 | 1,834 |
570,397 | 2009-02-20T17:03:00.000 | 0 | 0 | 0 | 1 | python,connection,twisted,reactor | 570,561 | 1 | true | 0 | 0 | Looking at this some more, I think I've come up with a solution, although hopefully there is a better way; this seems kind of weird.
Twisted has a class, ClientCreator that is used for producing simple single-use connections. It in theory does what I want; connects and returns a Deferred that fires when the connection... | 1 | 2 | 0 | This is part of a larger program; I'll explain only the relevant parts. Basically, my code wants to create a new connection to a remote host. This should return a Deferred, which fires once the connection is established, so I can send something on it.
I'm creating the connection with twisted.internet.interfaces.IReac... | With Twisted, how can 'connectionMade' fire a specific Deferred? | 1.2 | 0 | 0 | 1,036 |
570,433 | 2009-02-20T17:10:00.000 | 1 | 0 | 0 | 0 | python,ftp | 571,410 | 2 | false | 0 | 0 | Seems like any system that is automatically generating a file once an hour is likely to be using an automated naming scheme. Are you over thinking the problem by asking the server for the newest file instead of more easily parsing the file names?
This wouldn't work in all cases, and if the directory got large it mig... | 1 | 3 | 0 | I am using Python to connect to an FTP server that contains a new list of data once every hour. I am only connecting once a day, and I only want to download the newest file in the directory. Is there a way to do this? | How can I get the newest file from an FTP server? | 0.099668 | 0 | 1 | 1,672 |
570,912 | 2009-02-20T19:31:00.000 | 2 | 0 | 1 | 0 | python,scheduling | 570,965 | 3 | false | 0 | 0 | Here's one approach:
Start with S1, assign him the three people he wants at 9am, then go to S2 and try to schedule his meeting at 9am. Continue until you have a conflict, then move that meeting to 10am. Return to 9am for the next one. If there is a conflict at 10 also, move to 11, etc.
Once the program tries to sched... | 1 | 3 | 0 | I have to build a program that schedules based on certain rules. I'm not sure how to explain it, so let me give you an example..
You have Five People A,B,C,D,E. And you Have another set of people S1 S2 S3 S4 S5 S6 S7.
If A B C D and E are available every hour from 9 to 5, and S1 S2 S3 S4 S5 S6 and S7 have a list of 3 p... | How to program a schedule | 0.132549 | 0 | 0 | 9,285 |
573,618 | 2009-02-21T19:39:00.000 | 2 | 0 | 0 | 0 | python,django,web-applications,scheduled-tasks | 7,287,891 | 24 | false | 1 | 0 | I had something similar with your problem today.
I didn't wanted to have it handled by the server trhough cron (and most of the libs were just cron helpers in the end).
So i've created a scheduling module and attached it to the init .
It's not the best approach, but it helps me to have all the code in a single place an... | 1 | 567 | 0 | I've been working on a web app using Django, and I'm curious if there is a way to schedule a job to run periodically.
Basically I just want to run through the database and make some calculations/updates on an automatic, regular basis, but I can't seem to find any documentation on doing this.
Does anyone know how to se... | Set up a scheduled job? | 0.016665 | 0 | 0 | 206,437 |
574,068 | 2009-02-22T00:58:00.000 | 3 | 1 | 0 | 0 | python,deployment,wsgi | 612,622 | 9 | false | 1 | 0 | Apache httpd + mod_fcgid using web.py (which is a wsgi application).
Works like a charm. | 4 | 42 | 0 | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | How do YOU deploy your WSGI application? (and why it is the best way) | 0.066568 | 0 | 0 | 14,313 |
574,068 | 2009-02-22T00:58:00.000 | 1 | 1 | 0 | 0 | python,deployment,wsgi | 612,607 | 9 | false | 1 | 0 | We are using pure Paste for some of our web services. It is easy to deploy (with our internal deployment mechanism; we're not using Paste Deploy or anything like that) and it is nice to minimize the difference between production systems and what's running on developers' workstations. Caveat: we don't expect low laten... | 4 | 42 | 0 | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | How do YOU deploy your WSGI application? (and why it is the best way) | 0.022219 | 0 | 0 | 14,313 |
574,068 | 2009-02-22T00:58:00.000 | 1 | 1 | 0 | 0 | python,deployment,wsgi | 616,720 | 9 | false | 1 | 0 | Apache+mod_wsgi,
Simple, clean. (only four lines of webserver config), easy for other sysadimns to get their head around. | 4 | 42 | 0 | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | How do YOU deploy your WSGI application? (and why it is the best way) | 0.022219 | 0 | 0 | 14,313 |
574,068 | 2009-02-22T00:58:00.000 | 6 | 1 | 0 | 0 | python,deployment,wsgi | 635,680 | 9 | false | 1 | 0 | Nginx reverse proxy and static file sharing + XSendfile + uploadprogress_module. Nothing beats it for the purpose.
On the WSGI side either Apache + mod_wsgi or cherrypy server. I like to use cherrypy wsgi server for applications on servers with less memory and less requests.
Reasoning:
I've done benchmarks with differe... | 4 | 42 | 0 | Deploying a WSGI application. There are many ways to skin this cat. I am currently using apache2 with mod-wsgi, but I can see some potential problems with this.
So how can it be done?
Apache Mod-wsgi (the other mod-wsgi's seem to not be worth it)
Pure Python web server eg paste, cherrypy, Spawning, Twisted.web
as 2 bu... | How do YOU deploy your WSGI application? (and why it is the best way) | 1 | 0 | 0 | 14,313 |
575,081 | 2009-02-22T15:32:00.000 | 4 | 0 | 1 | 1 | python | 575,086 | 5 | false | 0 | 0 | It does close them.
Are you sure f.close() is getting called?
I just tested the same scenario and windows deletes the file for me. | 2 | 5 | 0 | I am on windows with Python 2.5. I have an open file for writing. I write some data. Call file close. When I try to delete the file from the folder using Windows Explorer, it errors, saying that a process still holds a handle to the file.
If I shutdown python, and try again, it succeeds. | Why doesn't Python release file handles after calling file.close()? | 0.158649 | 0 | 0 | 7,977 |
575,081 | 2009-02-22T15:32:00.000 | 0 | 0 | 1 | 1 | python | 30,957,893 | 5 | false | 0 | 0 | I was looking for this, because the same thing happened to me. The question didn't help me, but I think I figured out what happened.
In the original version of the script I wrote, I neglected to add in a 'finally' clause to the file in case of an exception.
I was testing the script from the interactive prompt and got a... | 2 | 5 | 0 | I am on windows with Python 2.5. I have an open file for writing. I write some data. Call file close. When I try to delete the file from the folder using Windows Explorer, it errors, saying that a process still holds a handle to the file.
If I shutdown python, and try again, it succeeds. | Why doesn't Python release file handles after calling file.close()? | 0 | 0 | 0 | 7,977 |
575,172 | 2009-02-22T16:31:00.000 | 4 | 0 | 0 | 0 | python,non-relational-database,portable-database | 575,197 | 9 | false | 0 | 0 | If you're used to thinking a relational database has to be huge and heavy like PostgreSQL or MySQL, then you'll be pleasantly surprised by SQLite.
It is relational, very small, uses a single file, has Python bindings, requires no extra priviledges, and works on Linux, Windows, and many other platforms. | 1 | 2 | 0 | I want to experiment/play around with non-relational databases, it'd be best if the solution was:
portable, meaning it doesn't require an installation. ideally just copy-pasting the directory to someplace would make it work. I don't mind if it requires editing some configuration files or running a configuration tool f... | portable non-relational database | 0.088656 | 1 | 0 | 3,510 |
576,963 | 2009-02-23T09:08:00.000 | 15 | 1 | 1 | 0 | python,obfuscation | 577,161 | 7 | false | 0 | 0 | Your problem space is underspecified. Is this for a command-line app? Is this code supposed to be used as a library?
In addition to the two other answers, you could embed the code into a binary. When it starts, decode the code and eval the string. This works for a shared library extension as well. You could also do tha... | 2 | 39 | 0 | Do you know of any tool that could assist me in obfuscating python code? | Python Code Obfuscation | 1 | 0 | 0 | 39,050 |
576,963 | 2009-02-23T09:08:00.000 | 5 | 1 | 1 | 0 | python,obfuscation | 577,067 | 7 | false | 0 | 0 | In many situations you can ship byte-compiled .pyc files instead of the .py source files. This gives you some level of obfuscation. As the pyobfuscate README suggests, this has limitations. But you may be able to combine the two approaches. | 2 | 39 | 0 | Do you know of any tool that could assist me in obfuscating python code? | Python Code Obfuscation | 0.141893 | 0 | 0 | 39,050 |
577,467 | 2009-02-23T12:20:00.000 | 11 | 0 | 1 | 1 | python,windows,cmd,command-line | 15,254,312 | 13 | false | 0 | 0 | The best option: os.system('pause') <-- this will actually display a message saying 'press any key to continue' whereas adding just raw_input('') will print no message, just the cursor will be available.
not related to answer:
os.system("some cmd command") is a really great command as the command can execute any batch... | 4 | 55 | 0 | I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.
After the script has been processed, the interpreter terminates and the output window is closed which makes it impossible to read script output.
What is the mo... | How to pause a script when it ends on Windows? | 1 | 0 | 0 | 124,670 |
577,467 | 2009-02-23T12:20:00.000 | 44 | 0 | 1 | 1 | python,windows,cmd,command-line | 4,130,571 | 13 | false | 0 | 0 | Try os.system("pause") — I used it and it worked for me.
Make sure to include import os at the top of your script. | 4 | 55 | 0 | I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.
After the script has been processed, the interpreter terminates and the output window is closed which makes it impossible to read script output.
What is the mo... | How to pause a script when it ends on Windows? | 1 | 0 | 0 | 124,670 |
577,467 | 2009-02-23T12:20:00.000 | 3 | 0 | 1 | 1 | python,windows,cmd,command-line | 41,732,172 | 13 | false | 0 | 0 | As to the "problem" of what key to press to close it, I (and thousands of others, I'm sure) simply use input("Press Enter to close"). | 4 | 55 | 0 | I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.
After the script has been processed, the interpreter terminates and the output window is closed which makes it impossible to read script output.
What is the mo... | How to pause a script when it ends on Windows? | 0.046121 | 0 | 0 | 124,670 |
577,467 | 2009-02-23T12:20:00.000 | 58 | 0 | 1 | 1 | python,windows,cmd,command-line | 577,488 | 13 | true | 0 | 0 | One way is to leave a raw_input() at the end so the script waits for you to press Enter before it terminates. | 4 | 55 | 0 | I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.
After the script has been processed, the interpreter terminates and the output window is closed which makes it impossible to read script output.
What is the mo... | How to pause a script when it ends on Windows? | 1.2 | 0 | 0 | 124,670 |
577,639 | 2009-02-23T13:33:00.000 | 2 | 0 | 0 | 0 | python,math,opengl | 577,672 | 2 | false | 0 | 1 | If you already have the code set up to render your scene, try adding a glRotate() call to the viewmodel matrix setup, to "rotate the camera" before rendering the scene. | 2 | 2 | 0 | In a "multitouch" environement, any application showed on a surface can be rotated/scaled to the direction of an user. Actual solution is to drawing the application on a FBO, and draw a rotated/scaled rectangle with the texture on it. I don't think it's good for performance, and all graphics cards don't provide FBO.
Th... | Rotating a glViewport? | 0.197375 | 0 | 0 | 3,051 |
577,639 | 2009-02-23T13:33:00.000 | 2 | 0 | 0 | 0 | python,math,opengl | 593,825 | 2 | true | 0 | 1 | There's no way to have a rotated viewport in OpenGL, you have to handle it manually. I see the following possible solutions :
Keep on using textures, perhaps using glCopyTexSubImage instead of FBOs, as this is basic OpenGL feature. If your target platforms are hardware accelerated, performance should be ok, depending ... | 2 | 2 | 0 | In a "multitouch" environement, any application showed on a surface can be rotated/scaled to the direction of an user. Actual solution is to drawing the application on a FBO, and draw a rotated/scaled rectangle with the texture on it. I don't think it's good for performance, and all graphics cards don't provide FBO.
Th... | Rotating a glViewport? | 1.2 | 0 | 0 | 3,051 |
579,310 | 2009-02-23T20:55:00.000 | 0 | 0 | 1 | 0 | python,formatting,string,integer | 579,349 | 12 | false | 0 | 0 | I don't think there are format operators for that, but you can simply divide by 1000 until the result is between 1 and 999 and then use a format string for 2 digits after comma. Unit is a single character (or perhaps a small string) in most cases, which you can store in a string or array and iterate through it after ea... | 1 | 66 | 0 | What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?
I'd like to show 7436313 as 7.44M, and 2345 as 2,34K.
Is there some % string formatting operator available for that? Or that could be done only by actually dividi... | formatting long numbers as strings in python | 0 | 0 | 0 | 40,163 |
579,524 | 2009-02-23T21:48:00.000 | 0 | 1 | 1 | 0 | python,ruby,converter | 579,627 | 8 | false | 0 | 0 | The hardest part would be preserving semantics.
Like how do you deal with metaclass assignments, or function decorators, or yield-based generators when going to Ruby? I have no Ruby experience so I don't know what is directly supported. | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 0 | 0 | 0 | 4,019 |
579,524 | 2009-02-23T21:48:00.000 | 0 | 1 | 1 | 0 | python,ruby,converter | 579,540 | 8 | false | 0 | 0 | As simple as coming up with enough clever regexps that convert the syntax correctly.
Ruby and python's syntax is close enough for this to be not very hard.
You might need to do abit of extra work to rewrite stuff that you have in python that doesn't exist in ruby like listing comprehension for instance. | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 0 | 0 | 0 | 4,019 |
579,524 | 2009-02-23T21:48:00.000 | 13 | 1 | 1 | 0 | python,ruby,converter | 579,549 | 8 | false | 0 | 0 | I think your teacher is fibbing - this is pretty hard. It is equivalent to writing a compiler/interpreter. I don't know how much time you have available for this project, but you are typically looking at several man-years of work. | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 1 | 0 | 0 | 4,019 |
579,524 | 2009-02-23T21:48:00.000 | 0 | 1 | 1 | 0 | python,ruby,converter | 579,595 | 8 | false | 0 | 0 | It sounds like your teacher is a bit of a practical joker! | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 0 | 0 | 0 | 4,019 |
579,524 | 2009-02-23T21:48:00.000 | 0 | 1 | 1 | 0 | python,ruby,converter | 579,546 | 8 | false | 0 | 0 | the language should not matter. pick the one you are most comfortable with strings in.
tips wise i would use a dictionary/look-up array for the keywords. The hardest part will be dealing with the white space in python | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 0 | 0 | 0 | 4,019 |
579,524 | 2009-02-23T21:48:00.000 | 0 | 1 | 1 | 0 | python,ruby,converter | 579,543 | 8 | false | 0 | 0 | First simple may mean that it does not take care of all the valid semantics of Python, but only a subset of this.
The first thing I would get would be a copy of the dragon book, which you can find in any university library. The second thing I would do would be to get a copy of the syntax and semantics of Python. | 6 | 5 | 0 | My teacher told me that if I wanted to get the best grade in our programming class, I should code a Simple Source Code Converter.
Python to Ruby (the simplest he said)
Now my question to you: how hard is it to code a simple source code converter for python to ruby. (It should convert file controlling, Control Stateme... | How do I code a source code converter from python to ruby? | 0 | 0 | 0 | 4,019 |
581,038 | 2009-02-24T09:15:00.000 | 1 | 0 | 0 | 0 | python,cherrypy | 582,467 | 5 | false | 1 | 0 | When you use mod_python on a threaded Apache server (the default on Windows), CherryPy runs in the same process as Apache. In that case, you almost certainly don't want CP to restart the process.
Solution: use mod_rewrite or mod_proxy so that CherryPy runs in its own process. Then you can autoreload to your heart's con... | 2 | 12 | 0 | Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major conc... | Python web programming | 0.039979 | 0 | 0 | 2,349 |
581,038 | 2009-02-24T09:15:00.000 | 8 | 0 | 0 | 0 | python,cherrypy | 581,356 | 5 | false | 1 | 0 | What is the best setup for a development environment?
Doesn't much matter. We use Django, which runs in Windows and Unix nicely. For production, we use Apache in Red Hat.
Is having to reload webserver to see the changes considered normal?
Yes. Not clear why you'd want anything different. Web application software sh... | 2 | 12 | 0 | Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major conc... | Python web programming | 1 | 0 | 0 | 2,349 |
583,048 | 2009-02-24T18:49:00.000 | 9 | 0 | 1 | 0 | python | 583,328 | 13 | false | 0 | 0 | It doesn't matter what year is it or what output devices you use (to some extent). Your code should be readable if possible by humans. It is hard for humans to read long lines.
It depends on the line's content how long it should be. If It is a log message then its length matters less. If it is a complex code then its b... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 1 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 6 | 0 | 1 | 0 | python | 583,137 | 13 | false | 0 | 0 | This is a good rule to keep to a large part of the time, but don't pull your hair out over it. The most important thing is that stylistically your code looks readable and clean, and keeping your lines to reasonable length is part of that.
Sometimes it's nicer to let things run on for more than 80 columns, but most of ... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 1 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 4 | 0 | 1 | 0 | python | 583,064 | 13 | false | 0 | 0 | I would suggest being willing to go beyond 80 columns. 80 columns is a holdover from when it was a hard limit based on various output devices.
Now, I wouldn't go hog wild...set a reasonable limit, but an arbitary limit of 80 columns seems a bit overzealous.
EDIT: Other answers are also clarifing this: it matters what ... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0.061461 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 3 | 0 | 1 | 0 | python | 583,080 | 13 | false | 0 | 0 | Strings are special because they tend to be long, so break them when you need and don't worry about it.
When your actual code starts bumping the 80 column mark it's a sign that you might want to break up deeply nested code into smaller logical chunks. | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0.046121 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 0 | 0 | 1 | 0 | python | 583,415 | 13 | false | 0 | 0 | Pick a style you like, apply a layer of common sense, and use it consistently.
PEP 8 is a style guide for libraries included as part of the Python standard library. It was never intended to be picked up as the style rules for all Python code. That said, there's no reason people shouldn't use it, but it's definitely n... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 4 | 0 | 1 | 0 | python | 583,713 | 13 | false | 0 | 0 | The 80 column count is one of the few places I disagree with the Python style guide. I'd recommend you take a look at the audience for your code. If everyone you're working with uses a modern IDE on a monitor with a reasonable resolution, it's probably not worth your time. My monitor is cheap and has a relatively we... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0.061461 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 0 | 0 | 1 | 0 | python | 30,898,395 | 13 | false | 0 | 0 | I do run into code that spills past 79 columns on every now and then. I've either broken them up with '\' (although recently, I've read about using parenthesis instead as a preferred alternative, so I'll give that a shot), or just let it be if it's no more than 15 or so past. And this coming from someone who indents ... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0 | 0 | 0 | 7,092 |
583,048 | 2009-02-24T18:49:00.000 | 3 | 0 | 1 | 0 | python | 583,109 | 13 | false | 0 | 0 | I deal with it by not worrying about the length of my lines. I know that some of the lines I write are longer than 80 characters but most of them aren't.
I know that my position is not considered "pythonic" by many and I understand their points. Part of being an engineer is knowing the trade-offs for each decision an... | 8 | 15 | 0 | I find myself breaking strings constantly just to get them on the next line. And of course when I go to change those strings (think logging messages), I have to reformat the breaks to keep them within the 80 columns.
How do most people deal with this? | Do you have a hard time keeping to 80 columns with Python? | 0.046121 | 0 | 0 | 7,092 |
586,517 | 2009-02-25T15:39:00.000 | 1 | 0 | 0 | 0 | jquery,python,django,django-models,csv | 588,212 | 6 | false | 1 | 0 | Look at csv module from stdlib. It contains presets for popualr CSV dialects like one produced by Excel.
Reader class support field mapping and if file contains column header it coes not depend on column order. For more complex logic, like looking up several alternative names for a field, you'll need to write your ow... | 2 | 2 | 0 | I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. ... | What are good ways to upload bulk .csv data into a webapp using Django/Python? | 0.033321 | 0 | 0 | 2,198 |
586,517 | 2009-02-25T15:39:00.000 | 1 | 0 | 0 | 0 | jquery,python,django,django-models,csv | 586,694 | 6 | false | 1 | 0 | If you'll copy excel table into clipboard and then paste results into notepad, you'll notice that it's tab separated. I once used it to make bulk import from most of table editors by copy-pasting data from the editor into textarea on html page.
You can use a background for textarea as a hint for number of columns and p... | 2 | 2 | 0 | I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. ... | What are good ways to upload bulk .csv data into a webapp using Django/Python? | 0.033321 | 0 | 0 | 2,198 |
587,647 | 2009-02-25T20:13:00.000 | 1 | 0 | 1 | 0 | python | 587,696 | 7 | false | 0 | 0 | Store your number as an integer. When you want to print it, add the leading zeros. This way you can easily do math without conversions, and it simplifies the thought process. | 3 | 11 | 0 | What would be the best way to increment a value that contains leading zeroes? For example, I'd like to increment "00000001". However, it should be noted that the number of leading zeroes will not exceed 30. So there may be cases like "0000012", "00000000000000099", or "000000000000045".
I can think of a couple ways,... | How to increment a value with leading zeroes? | 0.028564 | 0 | 0 | 6,032 |
587,647 | 2009-02-25T20:13:00.000 | -1 | 0 | 1 | 0 | python | 21,325,089 | 7 | false | 0 | 0 | "my code is in c"
int a[6]={0,0,0,0,0,0},i=5,k,p;
while(a[0]!=10)
{
do
{
for(p=0;p<=i;p++)
printf("%d",a[p]);
printf("\n");
delay(100);
a[i]++;
}while(a[i]!=10);
for(k=0;k<=i;k++)
if(a[i-k]==10)
{
a[i-(k+1)]++;
a[i-k]=0;... | 3 | 11 | 0 | What would be the best way to increment a value that contains leading zeroes? For example, I'd like to increment "00000001". However, it should be noted that the number of leading zeroes will not exceed 30. So there may be cases like "0000012", "00000000000000099", or "000000000000045".
I can think of a couple ways,... | How to increment a value with leading zeroes? | -0.028564 | 0 | 0 | 6,032 |
587,647 | 2009-02-25T20:13:00.000 | 1 | 0 | 1 | 0 | python | 587,655 | 7 | false | 0 | 0 | Determine the length, convert it to an integer, increment it, then convert it back to a string with leading zeros so that it has the same length as before. | 3 | 11 | 0 | What would be the best way to increment a value that contains leading zeroes? For example, I'd like to increment "00000001". However, it should be noted that the number of leading zeroes will not exceed 30. So there may be cases like "0000012", "00000000000000099", or "000000000000045".
I can think of a couple ways,... | How to increment a value with leading zeroes? | 0.028564 | 0 | 0 | 6,032 |
588,342 | 2009-02-25T23:09:00.000 | 3 | 0 | 0 | 1 | python,django,design-patterns,google-app-engine,django-apps | 591,169 | 2 | true | 1 | 0 | The Django implementation of apps is closely tied to Django operation as a framework - I mean plugging application using Django url mapping features (for mapping urls to view functions) and Django application component discovery (for discovering models and admin configuration). There is no such mechanisms in WebApp (I ... | 1 | 3 | 0 | Django has a very handy pattern known as "apps". Essentially, a self-contained plug-in that requires a minimal amount of wiring, configuring, and glue code to integrate into an existing project. Examples are tagging, comments, contact-form, etc. They let you build up large projects by gathering together a collection... | Is there a Django apps pattern equivalent in Google App Engine? | 1.2 | 0 | 0 | 715 |
588,749 | 2009-02-26T01:32:00.000 | 0 | 1 | 1 | 1 | python,packaging,setuptools,distutils | 40,901,455 | 10 | false | 0 | 0 | correct me if wrong, but I believe the question is how to DEPLOY the daemon. Set your app to install via pip and then make the entry_point a cli(daemon()). Then create an init script that simply runs $app_name & | 2 | 24 | 0 | I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable/script be handled?
Relatedly are there any common tools for setting up the daemon for running on b... | Python Daemon Packaging Best Practices | 0 | 0 | 0 | 16,678 |
588,749 | 2009-02-26T01:32:00.000 | 0 | 1 | 1 | 1 | python,packaging,setuptools,distutils | 588,835 | 10 | false | 0 | 0 | On Linux systems, the system's package manager (Portage for Gentoo, Aptitude for Ubuntu/Debian, yum for Fedora, etc.) usually takes care of installing the program including placing init scripts in the right places. If you want to distribute your program for Linux, you might want to look into bundling it up into the pro... | 2 | 24 | 0 | I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable/script be handled?
Relatedly are there any common tools for setting up the daemon for running on b... | Python Daemon Packaging Best Practices | 0 | 0 | 0 | 16,678 |
589,093 | 2009-02-26T04:19:00.000 | 0 | 0 | 0 | 1 | python,subprocess,popen | 589,104 | 3 | false | 0 | 0 | For instance, can I make a call through it and then another one after it without having to concatenate the commands into one long string?
Sounds like you're using shell=True. Don't, unless you need to. Instead use shell=False (the default) and pass in a command/arg list.
Is there a way to do multiple calls in the sam... | 2 | 3 | 0 | Is there a way to do multiple calls in the same "session" in Popen? For instance, can I make a call through it and then another one after it without having to concatenate the commands into one long string? | Python persistent Popen | 0 | 0 | 0 | 2,516 |
589,093 | 2009-02-26T04:19:00.000 | 3 | 0 | 0 | 1 | python,subprocess,popen | 589,282 | 3 | true | 0 | 0 | You're not "making a call" when you use popen, you're running an executable and talking to it over stdin, stdout, and stderr. If the executable has some way of doing a "session" of work (for instance, by reading lines from stdin) then, yes, you can do it. Otherwise, you'll need to exec multiple times.
subprocess.Popen ... | 2 | 3 | 0 | Is there a way to do multiple calls in the same "session" in Popen? For instance, can I make a call through it and then another one after it without having to concatenate the commands into one long string? | Python persistent Popen | 1.2 | 0 | 0 | 2,516 |
589,115 | 2009-02-26T04:33:00.000 | 1 | 1 | 0 | 1 | python,linux,pylons | 590,001 | 7 | false | 0 | 0 | If you want to be able to remove all the cruft but still be using a ‘mainstream’ distro rather than one cut down to aim at tiny devices, look at Slackware. You can happily remove stuff as low-level as sysvinit, cron and so on, without collapsing into dependency hell. And nothing in it relies on Perl or Python, so you c... | 4 | 2 | 0 | I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probabl... | Miminal Linux For a Pylons Web App? | 0.028564 | 0 | 0 | 602 |
589,115 | 2009-02-26T04:33:00.000 | 1 | 1 | 0 | 1 | python,linux,pylons | 895,583 | 7 | false | 0 | 0 | For this purpose, I'd like to build a minimal Linux platform...
So Why not try to use ArchLinux www.archlinux.org?
Also you can use virtualenv with Pylons in it. | 4 | 2 | 0 | I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probabl... | Miminal Linux For a Pylons Web App? | 0.028564 | 0 | 0 | 602 |
589,115 | 2009-02-26T04:33:00.000 | 0 | 1 | 0 | 1 | python,linux,pylons | 589,638 | 7 | false | 0 | 0 | debootstrap is your friend. | 4 | 2 | 0 | I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probabl... | Miminal Linux For a Pylons Web App? | 0 | 0 | 0 | 602 |
589,115 | 2009-02-26T04:33:00.000 | 0 | 1 | 0 | 1 | python,linux,pylons | 589,645 | 7 | false | 0 | 0 | Damn Small Linux? Slax? | 4 | 2 | 0 | I am going to be building a Pylons-based web application. For this purpose, I'd like to build a minimal Linux platform, upon which I would then install the necessary packages such as Python and Pylons, and other necessary dependencies. The other reason to keep it minimal is because this machine will be virtual, probabl... | Miminal Linux For a Pylons Web App? | 0 | 0 | 0 | 602 |
589,407 | 2009-02-26T06:44:00.000 | 0 | 0 | 0 | 1 | python,windows,unix,logging,file-io | 592,121 | 3 | false | 0 | 0 | One thing I've done is have python very temporarily rename the file. If we're able to rename it, then no other process is using it. I only tested this on Windows. | 1 | 9 | 0 | I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application.
Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows?
edit: I'll... | Python - How to check if a file is used by another application? | 0 | 0 | 0 | 22,009 |
590,007 | 2009-02-26T10:41:00.000 | 0 | 0 | 1 | 0 | python,ironpython,cpython | 590,029 | 8 | false | 0 | 0 | It also depends on whether you want your code to work on Linux. Dunno if IronPython will work on anything beside windows platforms. | 4 | 33 | 0 | How does IronPython stack up to the default Windows implementation of Python from python.org? If I am learning Python, will I be learning a subtley different language with IronPython, and what libraries would I be doing without?
Are there, alternatively, any pros to IronPython (not including .NET IL compiled classes) t... | Python or IronPython | 0 | 0 | 0 | 14,578 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.