Hey
Is it possible with python to set the timezone just like this in php:
date_default_timezone_set("Europe/London");
$Year = date('y');
$Month = date('m');
$Day = date('d');
$Hour = date('H');
$Minute = date('i');
I can't really install any other modules etc as I'm using shared web hosting.
Any ideas?
...
I wrote some code that I'd like to package as an egg. This is my directory structure:
src/
src/tests
src/tests/test.py # this has several tests for the movie name parser
src/torrent
src/torrent/__init__.py
src/torrent/movienameparser
src/torrent/movienameparser/__init__.py # this contains the code
I'd like to package this directory s...
I'm actually trying doing this in Java, but I'm in the process of teaching myself python and it made me wonder if there was an easy/clever way to do this with wrappers or something.
I want to know how many times a specific method was called inside another method. For example:
def foo(z):
#do something
return result
def bar(x,y...
One company with many branches across the world using the same app. Each branch's supervisor, signing into the same /admin, should see and be able to manage only their records across many models (blog, galleries, subscribed users, clients list, etc.).
How to solve it best within django? I need a flexible and reliable solution, not hack...
I'm confused by some behavior of my Mac OS X Terminal and my Django manage.py shell and pdb.
When I start a new terminal, the Standard Input is displayed as I type. However, if there is an error, suddenly Standard Input does not appear on the screen. This error continues until I shut down that terminal window.
The Input is still being ...
I have my Django site up and running, and everything works fine EXCEPT:
When I first go to my site http://127.0.0.1:8000
A popup box comes up and says
"The page at http://127.0.0.1:8000 says"
And just sits there
You have to hit OK before anything is displayed.
What is going on here?
...
I need to generate unique record id for the given unique string.
I tried using uuid format which seems to be good.
But we feel that is lengthly.
so we need to cutdown the uuid string 9f218a38-12cd-5942-b877-80adc0589315 to smaller. By removing '-' we can save 4 chars. What is the safest part to remove from uuid? We don't need unive...
Let's say I have a timezone like "2009-08-18 13:52:54-04". I can parse most of it using a line like this:
datetime.strptime(time_string, "%Y-%m-%d %H:%M:%S")
However, I can't get the timezone to work. There's a %Z that handles textual timezones ("EST", "UTC", etc) but I don't see anything that can parse "-04".
...
There is probably an easy answer for this, just not sure how to tease it out of my searches.
I adhere to PEP8 in my python code, and I'm currently using OptionParser for a script I'm writing. To prevent lines from going beyond a with of 80, I use the backslash where needed.
For example:
if __name__=='__main__':
usage = '%prog [op...
I just noted an annoying factor: Django requires either a restart of the server or CGI access to work. The first option is not feasible if you don't have access to the Apache server process. The second, as far as I know, is detrimental to performance, and in general the idea of running a CGI makes me uncomfortable.
I also recently saw a...
Hi. I have a file like below.
Sequence A.1.1 Bacteria
ATGCGCGATATAGGCCT
ATTATGCGCGCGCGC
Sequence A.1.2 Virus
ATATATGCGCCGCGCGTA
ATATATATGCGCGCCGGC
Sequence B.1.21 Chimpanzee
ATATAGCGCGCGCGCGAT
ATATATATGCGCG
Sequence C.21.4 Human
ATATATATGCCGCGCG
ATATAATATC
I want to make separate files for sequen...
Can I use python in firefox extensions? Does it work?
...
Say I have a dataset like
(1, 2, (3, 4), (5, 6), (7, 8, (9, 0)))
I want to convert it to a (semi) flat representation like,
(
(1, 2),
(1, 2, 3, 4),
(1, 2, 5, 6),
(1, 2, 7, 8),
(1, 2, 7, 8, 9, 0),
)
If you use this, (taken from SO)
def flatten(iterable):
for i, item in enumerate(iterable):
if hasattr(item, '__iter__'):
...
I am struggling to convert a url to a nested tuple.
# Convert this string
str = 'http://somesite.com/?foo=bar&key=val'
# to a tuple like this:
[(u'foo', u'bar'), (u'key', u'val')]
I assume I need to be doing something like:
url = 'http://somesite.com/?foo=bar&key=val'
url = url.split('?')
get = ()
for param in url[1].spl...
Python's datetime.strptime() is documented as supporting a timezone in the %Z field. So, for example:
In [1]: datetime.strptime('2009-08-19 14:20:36 UTC', "%Y-%m-%d %H:%M:%S %Z")
Out[1]: datetime.datetime(2009, 8, 19, 14, 20, 36)
However, "UTC" seems to be the only timezone I can get it to support:
In [2]: datetime.strptime('2009-08-...
Is there a way to get a thread dump from a running Python process?
Similar to kill -3 on a Java process.
...
I had a hard time formulating the title, so please edit it if you have a better one :)
I'm trying to display some statistics using the pygooglechart. And I am using Django to get the database items out of the database.
The database items has a datetime field wich i want to "sort on". What i really want is to populate a list like this.
...
What is the shortest hash (in filename-usable form, like a hexdigest) available in python? My application wants to save cache files for some objects. The objects must have unique repr() so they are used to 'seed' the filename. I want to produce a possibly unique filename for each object (not that many). They should not collide, but if th...
I've just become the system admin for my research group's cluster and, in this respect, am a novice. I'm trying to make a few tools to monitor the network and need help getting started implementing them with python (my native tongue).
For example, I would like to view who is logged onto remote machines. By hand, I'd ssh and who, but how...
I need to develop a graph database in python (I would enjoy if anybody can join me in the development. I already have a bit of code, but I would gladly discuss about it).
I did my research on the internet. in Java, neo4j is a candidate, but I was not able to find anything about actual disk storage. In python, there are many graph data m...