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 traceback to execute a function so i can dump the file so i can look at the file input and see were my code went wrong?
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 hampers readability and cannot be used if multiple functions reuse the same class. So, in addition to comments and docstrings, is there a mechanism to mark a class as "private" or "internal"? I am aware of the underscore mechanism, but as I understand it it only applies to variables, function and methods name.
"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 interpreter + standard library with my application? Would some other language like Lua, Javascript (Spidermonkey), Ruby, etc. be better for this use? Here's the criteria I'm weighing the different languages against: No/Few dependencies on externally installed packages Standard library with good feature set Nice language :) Doesn't result in a huge install package edit: I guess the question should be: How do I deploy my own python library + standard library with the installer of my program, so that it doesn't matter whether the platform already has python installed or not? edit2: One more clarification. I don't need info about specifics of linking C and Python code.
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 behaviour at runtime (monkey-patching) but not for the precompiled classes and it's generally frowned-upon. Ruby might be a little more different to your current experience: it has some flavour of Smalltalk (method-calling is more correctly message-sending for example). Its object-orientation is built-in from scratch, all classes are open to modification and it's an accepted - if slightly scary - practise. The community is smaller, the libraries less mature and documentation coverage is less. Both languages will have some level of broken backward compatibility in their next majopr releases, both have .Net implementations (IronPython is production, IronRuby getting there). Both have web frameworks that reflect their strengths (search SO for the Django/Rails debate). If I'd never seen Ruby, I'd be very happy working in Python, and have done so without suffering when necessary. I always found myself wishing I could do the work in Ruby. But that's my opinion, YMMV. Edit: Come to think of it, and even though it pains me, if you're seeking to leverage your knowledge of the .Net framework, you might be best off looking at IronPython, as it's more mature than the Ruby equivalent.
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 Ruby. Which one do you offer for me ? Pros and cons of them on each other? Is it worth learning them ? EDIT : Sorry I editted my post but not inform here, Ruby on Rails replaced with Ruby.
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 more about. Rails is nice for Ruby, but it's not the only one out there. For Python I like Pylons and Django. Pros and cons: Ruby is a little cleaner, language-wise, than Python. Python has a much larger set of modules. Is it worth learning? Yes, to both Python and Ruby.
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 Ruby. Which one do you offer for me ? Pros and cons of them on each other? Is it worth learning them ? EDIT : Sorry I editted my post but not inform here, Ruby on Rails replaced with Ruby.
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 Ruby. Which one do you offer for me ? Pros and cons of them on each other? Is it worth learning them ? EDIT : Sorry I editted my post but not inform here, Ruby on Rails replaced with Ruby.
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 application).
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 Ruby. Which one do you offer for me ? Pros and cons of them on each other? Is it worth learning them ? EDIT : Sorry I editted my post but not inform here, Ruby on Rails replaced with Ruby.
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 Ruby. Which one do you offer for me ? Pros and cons of them on each other? Is it worth learning them ? EDIT : Sorry I editted my post but not inform here, Ruby on Rails replaced with Ruby.
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 below is under the assumption that 'DefaultDomainName' will exist when an instance of the class is created (e.g. __init__() is called), but this does not seem to be the case, at least in my testing in python 2.5 on OS X. In the class Manager __init__() method, my print statements show as 'None'. And the print statements in the global function set_domain() further down shows 'None' prior to setting Manager.DefaultDomainName, and shows the expected value of 'test_domain' after the assignment. But when creating an instance of Manager again after calling set_domain(), the __init__() method still shows 'None'. Can anyone help me out, and explain what is going on here. It would be greatly appreciated. Thank you. # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. import boto from boto.utils import find_class class Manager(object): DefaultDomainName = boto.config.get('Persist', 'default_domain', None) def __init__(self, domain_name=None, aws_access_key_id=None, aws_secret_access_key=None, debug=0): self.domain_name = domain_name self.aws_access_key_id = aws_access_key_id self.aws_secret_access_key = aws_secret_access_key self.domain = None self.sdb = None self.s3 = None if not self.domain_name: print "1: %s" % self.DefaultDomainName print "2: %s" % Manager.DefaultDomainName self.domain_name = self.DefaultDomainName #self.domain_name = 'test_domain' if self.domain_name: boto.log.info('No SimpleDB domain set, using default_domain: %s' % self.domain_name) else: boto.log.warning('No SimpleDB domain set, persistance is disabled') if self.domain_name: self.sdb = boto.connect_sdb(aws_access_key_id=self.aws_access_key_id, aws_secret_access_key=self.aws_secret_access_key, debug=debug) self.domain = self.sdb.lookup(self.domain_name) if not self.domain: self.domain = self.sdb.create_domain(self.domain_name) def get_s3_connection(self): if not self.s3: self.s3 = boto.connect_s3(self.aws_access_key_id, self.aws_secret_access_key) return self.s3 def get_manager(domain_name=None, aws_access_key_id=None, aws_secret_access_key=None, debug=0): return Manager(domain_name, aws_access_key_id, aws_secret_access_key, debug=debug) def set_domain(domain_name): print "3: %s" % Manager.DefaultDomainName Manager.DefaultDomainName = domain_name print "4: %s" % Manager.DefaultDomainName def get_domain(): return Manager.DefaultDomainName def revive_object_from_id(id, manager): if not manager.domain: return None attrs = manager.domain.get_attributes(id, ['__module__', '__type__', '__lineage__']) try: cls = find_class(attrs['__module__'], attrs['__type__']) return cls(id, manager=manager) except ImportError: return None def object_lister(cls, query_lister, manager): for item in query_lister: if cls: yield cls(item.name) else: o = revive_object_from_id(item.name, manager) if o: yield o
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 be evaluated with the import statement when importing the modules containing these classes. So, these class variable Managers' self.domain_name values were set from DefaultDomainName before I even called set_domain(), and since I do not have the config files setup as ruds pointed out, that value was None. So, I have to rework my code a little, but thank you all for helping out a python newcomer.
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 below is under the assumption that 'DefaultDomainName' will exist when an instance of the class is created (e.g. __init__() is called), but this does not seem to be the case, at least in my testing in python 2.5 on OS X. In the class Manager __init__() method, my print statements show as 'None'. And the print statements in the global function set_domain() further down shows 'None' prior to setting Manager.DefaultDomainName, and shows the expected value of 'test_domain' after the assignment. But when creating an instance of Manager again after calling set_domain(), the __init__() method still shows 'None'. Can anyone help me out, and explain what is going on here. It would be greatly appreciated. Thank you. # Copyright (c) 2006,2007,2008 Mitch Garnaat http://garnaat.org/ # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, dis- # tribute, sublicense, and/or sell copies of the Software, and to permit # persons to whom the Software is furnished to do so, subject to the fol- # lowing conditions: # # # The above copyright notice and this permission notice shall be included # in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. import boto from boto.utils import find_class class Manager(object): DefaultDomainName = boto.config.get('Persist', 'default_domain', None) def __init__(self, domain_name=None, aws_access_key_id=None, aws_secret_access_key=None, debug=0): self.domain_name = domain_name self.aws_access_key_id = aws_access_key_id self.aws_secret_access_key = aws_secret_access_key self.domain = None self.sdb = None self.s3 = None if not self.domain_name: print "1: %s" % self.DefaultDomainName print "2: %s" % Manager.DefaultDomainName self.domain_name = self.DefaultDomainName #self.domain_name = 'test_domain' if self.domain_name: boto.log.info('No SimpleDB domain set, using default_domain: %s' % self.domain_name) else: boto.log.warning('No SimpleDB domain set, persistance is disabled') if self.domain_name: self.sdb = boto.connect_sdb(aws_access_key_id=self.aws_access_key_id, aws_secret_access_key=self.aws_secret_access_key, debug=debug) self.domain = self.sdb.lookup(self.domain_name) if not self.domain: self.domain = self.sdb.create_domain(self.domain_name) def get_s3_connection(self): if not self.s3: self.s3 = boto.connect_s3(self.aws_access_key_id, self.aws_secret_access_key) return self.s3 def get_manager(domain_name=None, aws_access_key_id=None, aws_secret_access_key=None, debug=0): return Manager(domain_name, aws_access_key_id, aws_secret_access_key, debug=debug) def set_domain(domain_name): print "3: %s" % Manager.DefaultDomainName Manager.DefaultDomainName = domain_name print "4: %s" % Manager.DefaultDomainName def get_domain(): return Manager.DefaultDomainName def revive_object_from_id(id, manager): if not manager.domain: return None attrs = manager.domain.get_attributes(id, ['__module__', '__type__', '__lineage__']) try: cls = find_class(attrs['__module__'], attrs['__type__']) return cls(id, manager=manager) except ImportError: return None def object_lister(cls, query_lister, manager): for item in query_lister: if cls: yield cls(item.name) else: o = revive_object_from_id(item.name, manager) if o: yield o
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 Monday-Sat of peoples connections, with a seventh graph representing all connections over the week with a string of 1's and 0's to indicate which days of the week the connections are made. This last graph is a break from the pajek format and is used by a seperate program written by another researcher. Pajek format has a large header, and then lists connections as (vertex1 vertex2) unordered pairs. It's difficult to store these pairs in a dictionary, because there are often multiple connections on the same day between two pairs. I'm wondering what the best way to output to these graphs are. Should I make the large single graph and have a second script deconstruct it into several smaller graphs? Should I keep seven streams open and as I determine a connection write to them, or should I keep some other data structure for each and output them when I can (like a queue)?
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 the list assigned to a variable Using cPickle's load Some other method (perhaps numpy?) Also, how can one benchmark such things reliably? Addendum: measuring this reliably is difficult, because import is cached so it can't be executed multiple times in a test. The loading with pickle also gets faster after the first time probably because page-precaching by the OS. Loading 1 million numbers with cPickle takes 1.1 sec the first time run, and 0.2 sec on subsequent executions of the script. Intuitively I feel cPickle should be faster, but I'd appreciate numbers (this is quite a challenge to measure, I think). And yes, it's important for me that this performs quickly. Thanks
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 lets the two instances share cookies. (If they really share the same subdomain, your current setting is probably fine.) make sure both Django instances use the same session backend (the same database, the same file directory, the same memcached config, etc.) make sure that anything put into the session makes sense in both Django databases: at the very least, that'll include the user id, since Django auth uses that to remember which user is logged in. All that said, I haven't actually tried all this, so you may still have trouble!
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 workflow. If the user bounces between applications while in this workflow they lose their session and have to start over. I dug through the Django session code and discovered that the: django.conf.settings.SECRET_KEY is used to perform an integrity check on the sessions on each request. If the integrity check fails, a new session is created. Realizing this, I changed the secret key in each of these applications to use the same value, thinking this would allow the integrity check to pass and allow them to share Django sessions. However, it didn't seem to work. Is there a way to do this? Am I missing something else? Thanks in advance
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 probably not a good idea. If you want some kind of single-sign-on, look into something like django-cas. You'll still have 2 sessions (as you should), but the user will only log in once.
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 workflow. If the user bounces between applications while in this workflow they lose their session and have to start over. I dug through the Django session code and discovered that the: django.conf.settings.SECRET_KEY is used to perform an integrity check on the sessions on each request. If the integrity check fails, a new session is created. Realizing this, I changed the secret key in each of these applications to use the same value, thinking this would allow the integrity check to pass and allow them to share Django sessions. However, it didn't seem to work. Is there a way to do this? Am I missing something else? Thanks in advance
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.path. After that deployment is as simple as cloning or checking out the VCS repository to wherever you want to use it. This has two added benefits: Version mismatches; your software always uses the version that you tested it with, and not the version that was available at the time of deployment. If multiple people work on the project, nobody else has to deal with installing the dependencies. When it's time to update a component's version, update it in your VCS and then propagate the update to your deployments via it.
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 that are bugging me in the whole business are: What is the preferred way to re-use an existing Django app? Where do I put it and how do I reference it? From what I understand, the recommendation is to put it on your "PYTHONPATH", but that breaks as soon as I need to deploy my app to a remote location that I have limited access to (e.g. on a hosting service). So, if I develop my site on my local computer and intend to deploy it on an ISP where I only have ftp access, how do I re-use 3rd party Django apps so that if I deploy my site, the site keeps working (e.g. the only thing I can count on is that the service provider has Python 2.5 and Django 1.x installed)? How do I organize my Django project so that I could easily deploy it along with all of the reusable apps I want to use?
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 dictionary. A list will still require some kind of scan (straight iteration or binary search if sorted). With that said, if you don't require some of the features of a DB then don't use one but if you just think MySQL is too heavy then +1 on the Sqlite suggestion from earlier. It gives you most of the features you'd want while using a database without the concurrency overhead.
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 database at all. So my plan is to export the database tables to a set of files (not many -- it's a pretty simple database; it's big in that it has a lot of rows, but only a few tables, each of which has just two or three columns). Then I plan to read the data in, and have a set of functions which provide access to and operations on the data. My question is this: is there a preferred way to convert a set of database tables to classes and objects? For example, if I have a table which contains fruit, where each fruit has an id and a name, would I have a "CollectionOfFruit" class which contains a list of "Fruit" objects, or would I just have a "CollectionOfFruit" class which contains a list of tuples? Or would I just have a list of Fruit objects? I don't want to add any extra frameworks, because I want this code to be easy to transfer to different machines. So I'm really just looking for general advice on how to represent data that might more naturally be stored in database tables, in objects in Python. Alternatively, is there a good book I should read that would point me in the right direction on this?
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 database at all. So my plan is to export the database tables to a set of files (not many -- it's a pretty simple database; it's big in that it has a lot of rows, but only a few tables, each of which has just two or three columns). Then I plan to read the data in, and have a set of functions which provide access to and operations on the data. My question is this: is there a preferred way to convert a set of database tables to classes and objects? For example, if I have a table which contains fruit, where each fruit has an id and a name, would I have a "CollectionOfFruit" class which contains a list of "Fruit" objects, or would I just have a "CollectionOfFruit" class which contains a list of tuples? Or would I just have a list of Fruit objects? I don't want to add any extra frameworks, because I want this code to be easy to transfer to different machines. So I'm really just looking for general advice on how to represent data that might more naturally be stored in database tables, in objects in Python. Alternatively, is there a good book I should read that would point me in the right direction on this?
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 database at all. So my plan is to export the database tables to a set of files (not many -- it's a pretty simple database; it's big in that it has a lot of rows, but only a few tables, each of which has just two or three columns). Then I plan to read the data in, and have a set of functions which provide access to and operations on the data. My question is this: is there a preferred way to convert a set of database tables to classes and objects? For example, if I have a table which contains fruit, where each fruit has an id and a name, would I have a "CollectionOfFruit" class which contains a list of "Fruit" objects, or would I just have a "CollectionOfFruit" class which contains a list of tuples? Or would I just have a list of Fruit objects? I don't want to add any extra frameworks, because I want this code to be easy to transfer to different machines. So I'm really just looking for general advice on how to represent data that might more naturally be stored in database tables, in objects in Python. Alternatively, is there a good book I should read that would point me in the right direction on this?
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 there then it's to extract the underlying requirements of the app and then write code against those requirements.
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 database at all. So my plan is to export the database tables to a set of files (not many -- it's a pretty simple database; it's big in that it has a lot of rows, but only a few tables, each of which has just two or three columns). Then I plan to read the data in, and have a set of functions which provide access to and operations on the data. My question is this: is there a preferred way to convert a set of database tables to classes and objects? For example, if I have a table which contains fruit, where each fruit has an id and a name, would I have a "CollectionOfFruit" class which contains a list of "Fruit" objects, or would I just have a "CollectionOfFruit" class which contains a list of tuples? Or would I just have a list of Fruit objects? I don't want to add any extra frameworks, because I want this code to be easy to transfer to different machines. So I'm really just looking for general advice on how to represent data that might more naturally be stored in database tables, in objects in Python. Alternatively, is there a good book I should read that would point me in the right direction on this?
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 that right first. A "collection" may -- or may not -- be an artificial construct that's part of the solution algorithm, not really a proper part of the problem. Usually collections are part of the problem, and you should design those classes, also. Other times, however, the collection is an artifact of having used a database, and a simple Python list is all you need. Still other times, the collection is actually a proper mapping from some unique key value to an entity, in which case, it's a Python dictionary. And sometimes, the collection is a proper mapping from some non-unique key value to some collection of entities, in which case it's a Python collections.defaultdict(list). Start with the fundamental, real-world-like entities. Those get class definitions. Collections may use built-in Python collections or may require their own classes.
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 database at all. So my plan is to export the database tables to a set of files (not many -- it's a pretty simple database; it's big in that it has a lot of rows, but only a few tables, each of which has just two or three columns). Then I plan to read the data in, and have a set of functions which provide access to and operations on the data. My question is this: is there a preferred way to convert a set of database tables to classes and objects? For example, if I have a table which contains fruit, where each fruit has an id and a name, would I have a "CollectionOfFruit" class which contains a list of "Fruit" objects, or would I just have a "CollectionOfFruit" class which contains a list of tuples? Or would I just have a list of Fruit objects? I don't want to add any extra frameworks, because I want this code to be easy to transfer to different machines. So I'm really just looking for general advice on how to represent data that might more naturally be stored in database tables, in objects in Python. Alternatively, is there a good book I should read that would point me in the right direction on this?
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 buffer from appearing? Also, how can I send painful electric shocks to the programmer who thought unexpectedly interrupting my train of thought with an empty buffer was a good idea? Edit: Apparently, there are uses for this behavior, most notably in seeing the output of a program. That's fine, but if there's no output (as in the program with which I'm tinkering), it is really dumb to cut my buffer in half with a blank window.
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 buffer from appearing? Also, how can I send painful electric shocks to the programmer who thought unexpectedly interrupting my train of thought with an empty buffer was a good idea? Edit: Apparently, there are uses for this behavior, most notably in seeing the output of a program. That's fine, but if there's no output (as in the program with which I'm tinkering), it is really dumb to cut my buffer in half with a blank window.
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 break at that location when I run the debugger. Am I missing some PyDev configuration? In other debuggers I have used, this behavior indicates a problem relating the debug information with the source code. Any ideas on next steps would be a help. I also have the site-packages configured in PyDev to be in my PYTHONPATH I am using Eclipse on Max OS X if that helps. Thanks
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 break at that location when I run the debugger. Am I missing some PyDev configuration? In other debuggers I have used, this behavior indicates a problem relating the debug information with the source code. Any ideas on next steps would be a help. I also have the site-packages configured in PyDev to be in my PYTHONPATH I am using Eclipse on Max OS X if that helps. Thanks
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 be extracted then you have found a whole world of pain! Using pdftotext would be a simple solution that would work in a majority of cases but it is by no means 100% successful. We have found many examples of PDFs that pdftotext cannot extract from but Java libraries such as iText and PDFBox 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 (the "file" command on the bash uses it). This does exactly the same check as in (1) Take a lib and try to read the page-count out of the file. If the lib is able to read a pagecount it should be a valid pdf. Problem: I dont know a lib for python which can do this So anybody got any solutions for a lib or another trick?
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 rolling my own chat server? Maybe like a different process I could run next to my game server process?
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 cleanest way to convert an integer to base64 (and back again) using Python. The base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.
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 converting just the digits (0-9) to a 64 character encoding. You are converting 3 bytes into 4 bytes so you are guaranteed your base64 encoded string would be 33.33% longer.
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 cleanest way to convert an integer to base64 (and back again) using Python. The base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.
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 maybe somebody has patched cloudfiles?
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 existing html elements, divs, images, styles etc gets converted neatly to an aspx page (too much ;) ). Any existing tools/scripts/utilities to do the same?
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!) use WebClient or HttpRequest, etc to open a connection to the old server and download the rendered HTML. Use the HTML agility toolkit (very slick) to extract the content that I'm interested in - in our case, this is always inside if a div with the class "bdy". Throw this into a cache - a SQL table in this example. Each hit checks the cache and either a)retrieves the page and builds the cache entry, or b) just gets the page from the cache. An aspx page built specifically for displaying legacy content receives the rewrite request and displays the relevant content from the legacy page inside of an asp literal control. The cache is there for performance - since the first request for a given page has a minimum of two hits - one from the browser to the new server, one from the new server to the old server - I store cachable data on the new server so that subsequent requests don't have to go back to the old server. We also cache images, css, scripts, etc. It gets messy when you have to handle forms, cookies, etc, but these can all be stored in your cache and passed through to the old server with each request if necessary. I also store content expiration dates and other headers that I get back from the legacy server and am sure to pass those back to the browser when rendering the cached page. Just remember to take as content-agnostic an approach as possible. You're effectively building an in-page web proxy that lets IIS render old ASP the way it wants, and manipulating the output. Works very well - I have all of the old pages working seamlessly within our ASP.NET app. This saved us a solid year of development time that would have been required if we had to touch every legacy asp page. Good luck!
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 existing html elements, divs, images, styles etc gets converted neatly to an aspx page (too much ;) ). Any existing tools/scripts/utilities to do the same?
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 things in Python!)
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 exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python. Am I really missing something? (Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)
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 exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python. Am I really missing something? (Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)
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 exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python. Am I really missing something? (Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)
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 exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python. Am I really missing something? (Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)
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 see such things in use and say, "Wow! That's awesome! Two lines of code and it's crystal clear!" So go find some pythonic code that you find interesting and start reading it and understanding it. The knowledge will stay in your head better if you see everything in the context of a working program.
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 exciting development work and may hardly be a candidate for revealing the true power of Python but I'd still like the opportunity to have my mind blown. I develop mostly in C# and I find that my Python code looks awfully similar in structure and style to a lot of my C# code. In other words I feel like I'm thinking in C# but writing in Python. Am I really missing something? (Note: I realize this isn't so much a programming question and it's quite broad and there may not be a definitive answer so mod me down into oblivion if you have to.)
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 modified XML document to does not seem to accept the lowercase versions. Is there a way to prevent this behavior in BeautifulSoup?
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 use.
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 beyond just game design.
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 between Windows and Ubuntu so something that "just works" on both platforms would be really helpful. Any suggestions?
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 move away from the built-in admin interface. Then you can fool around with multiple, partially related forms on a single web page. This is a bunch of template stuff to present all the forms on a single page. Then you have to write the view function to read and validated the various form things and do the various object saves(). "Is it a design issue if I break down and hand-code everything?" No, it's just a lot of time for not much benefit.
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 creating a Ticket and finally creating a Note assigned to the new ticket. Since I'm fairly new to Django, I tend to work iteratively, trying out new features each time. I've played with ModelForms but I want to hide some of the fields and do some complex validation. It seems like the level of control I'm looking for either requires formsets or doing everything by hand, complete with a tedious, hand-coded template page, which I'm trying to avoid. Is there some lovely feature I'm missing? Does someone have a good reference or example for using formsets? I spent a whole weekend on the API docs for them and I'm still clueless. Is it a design issue if I break down and hand-code everything?
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 numpy?
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 is established. I didn't think I could use this, though, since I'd lose the ability to pass arguments to the protocol constructor, and therefore have no way to share state between connections. However, I just realized that the ClientFactory constructor does accept *args to pass to the protocol constructor. Or at least it looks like it; there is virtually no documentation for this. In that case, I can give it a reference to my factory (or whatever else, if the factory is no longer necessary). And I get back the Deferred that fires when the connection is established.
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.IReactorSSL.connectSSL. That calls buildProtocol on my ClientFactory instance to get a new connection (twisted.internet.protocol.Protocol) object, and returns a twisted.internet.interfaces.IConnector. When the connection is started, Twisted calls startedConnecting on the factory, giving it the IConnector. When the connection is actually made, the protocol's connectionMade callback is called, with no arguments. Now, if I only needed one connection per host/port, the rest would be easy. Before calling connectSSL, I would create a Deferred and put it in a dictionary keyed on (host, port). Then, in the protocol's connectionMade, I could use self.transport.getPeer() to retrieve the host/port, use it to look up the Deferred, and fire its callbacks. But this obviously breaks down if I want to create more than one connection. The problem is that I can't see any other way to associate a Deferred I created before calling connectSSL with the connectionMade later on.
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 might become time consuming to get the file listing. But it seems likely to work in most cases.
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 schedule a meeting after hours, you'll know you've hit a case where all the meetings aren't possible in a single day.
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 people they want to see from {A,B,C,D,E} That's my problem and I'm not sure where to begin... Thanks for your help!
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 and with its execution related to the main app.
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 set this up? To clarify: I know I can set up a cron job to do this, but I'm curious if there is some feature in Django that provides this functionality. I'd like people to be able to deploy this app themselves without having to do much config (preferably zero). I've considered triggering these actions "retroactively" by simply checking if a job should have been run since the last time a request was sent to the site, but I'm hoping for something a bit cleaner.
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 but with reverse proxy from nginx, apache2 etc, with good static file handling Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? I want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.
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 latency out of Paste itself because of the heavyweight nature of our requests. In some crude benchmarking we did we weren't getting fantastic results; it just ended up being moot due to the expense of our typical request handler. So far it has worked fine. Static data has been handled by completely separate (and somewhat "organically" grown) stacks, including the use of S3, Akamai, Apache and IIS, in various ways.
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 but with reverse proxy from nginx, apache2 etc, with good static file handling Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? I want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.
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 but with reverse proxy from nginx, apache2 etc, with good static file handling Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? I want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.
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 different tools for different popular solutions. I have more experience with lower level TCP/IP than web development, especially http implementations. I'm more confident that I can recognize a good http server than I can recognize a good web framework. I know Twisted much more than Django or Pylons. The http stack in Twisted is still not up to this but it will be there.
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 but with reverse proxy from nginx, apache2 etc, with good static file handling Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? I want to know how you do it, and why it is the best way to do it. I would absolutely love you to bore me with details about the whats and the whys, application specific stuff, etc. I will upvote any non-insane answer.
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 an exception while the file was open. What I didn't realize was that the file object wasn't immediately garbage-collected. After that, when I ran the script (still from the same interactive session), even though the new file objects were being closed, the first one still hadn't been, and so the file handle was still in use, from the perspective of the operating system. Once I closed the interactive prompt, the problem went away, at which I remembered that exception occurring while the file was open and realized what had been going on. (Moral: Don't try to program on insufficient sleep. : ) ) Naturally, I have no idea if this is what happened in the case of the original poster, and even if the original poster is still around, they may not remember the specific circumstances, but the symptoms are similar, so I thought I'd add this as something to check for, for anyone caught in the same situation and looking for an answer.
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 for first time usage. accessible from python works on both windows and linux What can you recommend for me? Essentially, I would like to be able to install this system on a shared linux server where I have little user privileges.
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 that with byte code, I think, but it wouldn't be as simple as calling Py_EvalCode. py2exe or freeze are other solution, which convert the code into an executable. It just includes the code in the binary, and doesn't do any sort of serious obsfucation, but it's still harder than opening a .py file. You could write the code in Cython, which is similar to Python and writes Python extension files in C, for use as a .so. That's perhaps the hardest of these to reverse engineer and still give you a high-level language for develoment. They are all hackable, as are all solutions. How hard to you want it to be?
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 file/cmd commands.
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 most straightforward way to keep the interpreter window open until any key is pressed? In batch files, one can end the script with pause. The closest thing to this I found in python is raw_input() which is sub-optimal because it requires pressing the return key (instead of any key).
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 most straightforward way to keep the interpreter window open until any key is pressed? In batch files, one can end the script with pause. The closest thing to this I found in python is raw_input() which is sub-optimal because it requires pressing the return key (instead of any key).
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 most straightforward way to keep the interpreter window open until any key is pressed? In batch files, one can end the script with pause. The closest thing to this I found in python is raw_input() which is sub-optimal because it requires pressing the return key (instead of any key).
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 most straightforward way to keep the interpreter window open until any key is pressed? In batch files, one can end the script with pause. The closest thing to this I found in python is raw_input() which is sub-optimal because it requires pressing the return key (instead of any key).
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. The idea is to clip the rendering viewport in the direction of user. Since glViewport cannot be used for that, is another way exist to achieve that ? (glViewport use (x, y, width, height), and i would like (x, y, width, height, rotation from center?)) PS: rotating the modelview or projection matrix will not help, i would like to "rotate the clipping plan" generated by glViewport. (only part of the all scene).
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 on the number of viewports you need on your desk, as this is a very common use case nowadays. Without textures, you could setup your glViewport to the screen-aligned bounding rectangle (rA) of your rotated viewport (rB) (setting also proper scissor testing area). Then draw a masking area, possibly only in depth or stencil buffer, filling the (rA - rB) area, that will prevent further drawing on those pixels. Then draw normally your application, using a glRotate to adjust you projection matrix, so that the rendering is properly oriented according to rB.
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. The idea is to clip the rendering viewport in the direction of user. Since glViewport cannot be used for that, is another way exist to achieve that ? (glViewport use (x, y, width, height), and i would like (x, y, width, height, rotation from center?)) PS: rotating the modelview or projection matrix will not help, i would like to "rotate the clipping plan" generated by glViewport. (only part of the all scene).
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 each divide.
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 dividing by 1000 in a loop and constructing result string step by step?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 Statements, etc.) Do you have any tips for me? Which language should I use to code the converter (C#, Python or Ruby)?
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 content. :)
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 concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all. What is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example? Is it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy. How exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources? Python supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations? Big thanks!
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 shouldn't be dynamic. Content yes. Software no. In Django, we develop without using a web server of any kind on our desktop. The Django "runserver" command reloads the application under most circumstances. For development, this works great. The times when it won't reload are when we've damaged things so badly that the app doesn't properly. What is the best setup to deploy a working Python app to production and why? "Best" is undefined in this context. Therefore, please provide some qualification for "nest" (e.g., "fastest", "cheapest", "bluest") Is it worth diving straight with a framework or to roll something simple of my own? Don't waste time rolling your own. We use Django because of the built-in admin page that we don't have to write or maintain. Saves mountains of work. How exactly are Python apps served if I have to reload httpd to see the changes? Two methods: Daemon - mod_wsgi or mod_fastcgi have a Python daemon process to which they connect. Change your software. Restart the daemon. Embedded - mod_wsgi or mod_python have an embedded mode in which the Python interpreter is inside the mod, inside Apache. You have to restart httpd to restart that embedded interpreter. Do I need to look into using multi-threaded? Yes and no. Yes you do need to be aware of this. No, you don't need to do very much. Apache and mod_wsgi and Django should handle this for you.
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 concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all. What is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example? Is it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy. How exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources? Python supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations? Big thanks!
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 big length won't be helping to comprehend it.
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 the time I can write my code such that it's short and concise and fits in 80 or less. As some responders point out the limit of 80 is rather dated, but it's not bad to have such a limit and many people have terminals Here are some of the things that I keep in mind when trying to restrict the length of my lines: is this code that I expect other people to use? If so, what's the standard that those other people and use for this type of code? do those people have laptops, use giant fonts, or have other reasons for their screen real estate being limited? does the code look better to me split up into multiple lines, or as one long line? This is a stylistic question, but style is really important because you want people to read and understand your code.
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 you're breaking. Strings can more often be "special cases" where you may want to bend the rules a bit, for the sake of clarity. If your code, on the other hand, is getting long, that's a good time to look at where it is logical to break it up.
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 not a set of hard rules. Like any style, there is no single correct way and the most important thing is consistency.
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 weak resolution, but I can still fit 140 columns plus scroll bars, line markers, break markers, and a separate tree-view frame on the left. However, you will probably end up following some kind of limit, even if it's not a fixed number. With the exception of messages and logging, long lines are hard to read. Lines that are broken up are also harder to read. Judge each situation on its own, and do what you think will make life easiest for the person coming after you.
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 only 2, not 4 spaces (I know, shame on me :\ )! It isn't entirely science. It's also part style, and sometimes, keeping things on one line is just easier to manage or read. Other times, excessive side-to-side scrolling can be worse. Much of the time has to do with longer variable names. For variables beyond temp values and iterators, I don't want to reduce them to 1 to 5 letters. These that are 7 to 15 characters long actually do provide context as to their uses and what classes they refer to. When I need to print stuff out where parts of the output are dynamic, I'll replace those portions with function calls that cuts down on the conditional statements and sheer content that would've been in that body of code.
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 and then making the decision that you think is the best.
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 own implementation.
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. Are there good tools or even basic rules on how to accept different formats of the csv file? The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled "Email", but it may say "Primary Email", "Email Address"), or missing additional data columns. Any good examples of CSV upload functionality that is very permissive and user friendly? Also, how do I tell the user to export as CSV data? I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books. Are there other popular data formats that I should accept?
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 place your headers at the top suggesting the order for a user. Javascript will process pasted data and display them to the user immediately with simple prevalidation making it easy to fix an error and repaste. Then import button is clicked, data is validated again and import results are displayed. Unfortunately, I've never heard any feedback about whenever this was easy to use or not. Anyway, I still see it as an option when implementing bulk import.
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. Are there good tools or even basic rules on how to accept different formats of the csv file? The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled "Email", but it may say "Primary Email", "Email Address"), or missing additional data columns. Any good examples of CSV upload functionality that is very permissive and user friendly? Also, how do I tell the user to export as CSV data? I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books. Are there other popular data formats that I should accept?
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, but I want to see if someone comes up with something slick.
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, but I want to see if someone comes up with something slick.
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, but I want to see if someone comes up with something slick.
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 guess you think of WebApp framework when you refer to AppEngine, which is rather platform) itself - you have to write them by yourself then persuade people to write such applications in a way that will work with your url plugger and component discovery after plugging app to the rest of site code. There are generic pluggable modules, ready to use with AppEngine, like sharded counters or GAE utilities library, but they do not provide such level of functionality like Django apps (django-registration for example). I thing this comes from much greater freedom of design (basically, on GAE you can model your app after Django layout or after any other you might think of) and lack of widely used conventions.
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 of useful apps, rather than writing everything from scratch. The apps you do end up writing can be made portable so you can recycle them in other projects. Does this pattern exist in Google App Engine? Is there any way to create self-contained apps that can be easily be dropped into an App Engine project? Right off the bat, the YAML url approach looks like it could require a significant re-imagining to the way its done in Django. Note: I know I can run Django on App Engine, but that's not what I'm interested in doing this time around.
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 boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)?
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 proper format for various distributions' package managers. This advice is obviously irrelevant on systems which don't have package managers (Windows, and Mac I think).
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 boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)?
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 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? Any reason you can't just create two Popen instances and wait/communicate on each as necessary? That's the normal way to do it, if I understand you correctly.
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 is (mostly) just a wrapper around execvp(3)
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 can easily remove them (and install whichever version of Python your app prefers to use).
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, probably over KVM, and will eventually be replicated in some cloud environment. What would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.
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, probably over KVM, and will eventually be replicated in some cloud environment. What would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.
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, probably over KVM, and will eventually be replicated in some cloud environment. What would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.
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, probably over KVM, and will eventually be replicated in some cloud environment. What would you use to do this? I am thinking of using Fedora 10's AOS iso, but would love to understand all my options.
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 try and clarify. Is there a way to check if the current file has been opened by another application? I'd like to start with this question. Whether those other application read/write is irrelevant for now. I realize it is probably OS dependent, so this may not really be python related right now.
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) that would make it more attractive an option?
Python or IronPython
0
0
0
14,578