How to convert hex string to integer in Python ?
How to convert x = "0x000000001" # hex number string to y = "1" ...
How to convert x = "0x000000001" # hex number string to y = "1" ...
Hello, I have a python program/file that I want to run repeatedly and calculate the averages of some variables over these runs. To do so, I thought it might be convenient to convert this program into a function or a class. One way I can think of is to add a def Main(): line at the top and indent every line manually within it. Is the...
Hello, this is my first question. I'm trying to execute a SQL query in django (south migration): from django.db import connection # ... class Migration(SchemaMigration): # ... def transform_id_to_pk(self, table): try: db.delete_primary_key(table) except: pass finally: ...
Hi, I'm trying to use memcache to cache data retrevied from the datastore. Storing stings works fine. But can't one store an object? I get an error "TypeError: 'str' object is not callable" when trying to store with this: pageData = StandardPage(page) memcache.add(memcacheid, pageData, 60) I've read in the documentation that it r...
I have file with extension .dwg (AutoCAD) and I want to call that file from python console and present on web. Have any modules for .dwg extension or some other solution. ...
I'm trying to compile Python 2.6 for 64bit, I tried various compile commands but not sure whether those are correct ./configure --with-universal-archs=32-bit --prefix="$HOME/python" make make install What is the correct syntax ... ? ...
Is it possible to calculate Dawn, Dusk, and sunset times using PyEphem? I've used PyEphem to produce day and night time, but I didn't find anything on sunset/dusk/dawn ...
I have list in python which has following entries name-1 name-2 name-3 name-4 name-1 name-2 name-3 name-4 name-1 name-2 name-3 name-4 I would like remove name-1 from list except its first appearance -- resultant list should look like name-1 name-2 name-3 ...
I use the following code to log a map, it is fast when it only contains zeroes, but as soon as there is actual data in the map it becomes unbearably slow... Is there any way to do this faster? log_file = open('testfile', 'w') for i, x in ((i, start + i * interval) for i in range(length)): log_file.write('%-5d %8.3f %13g %13g %13g %1...
First of all, to clarify my goal: There exist two programs written in C in our laboratory. I am working on a Proxy Server (bidirectional) for them (which will also mainpulate the data). And I want to write that proxy server in Python. It is important to know that I know close to nothing about these two programs, I only know the definitio...
In Perl I would do something like this for taking different fields in a regexp, separating different fields by () and getting them using $ foreach $line (@lines) { $line =~ m/(.*?):([^-]*)-(.*)/; $field_1 = $1 $field_2 = $2 $field_3 = $3 } How could I do something like this in Python? ...
I have very large data set it is almost 450000 lines and two rows, i want to compute adjacency matrix using python, because previously i have tried to do it in matlab, and it shows memory error because of large data values. my data values also start from 100 and goes upto 450000, Anyone can help me in this issue, as i am new to python....
Hello guys, I am looking for displaying Forecast information in my Django Website. Do you have any idea of how I can do that ? I looked at https://registration.weather.com/ursa/wow/ but it is in english and I didn't find anyway to put it in French. I looked at libgweather, but it didn't helps me a lot. Do you know how I can do that ?...
from sqlalchemy.orm import relation, backref from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey, Date, Sequence from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class GUI_SCENARIO(Base): __tablename__ = 'GUI_SCENARIO' Scenario_ID = Column(Integer, primary_key=True) De...
I want to parse HTML with lxml using XPath expressions. My problem is matching for the contents of a tag: For example given the <a href="http://something">Example</a> element I can match the href attribute using .//a[@href='http://something'] but the given the expression .//a[.='Example'] or even .//a[contains(.,'Examp...
Hi, I want to map a Tag entity using declarative method with sqlachemy. A tag can have a parent (another Tag). I have: class Tag(Base): __tablename__ = 'tag' id = Column(Integer, primary_key=True) label = Column(String) def __init__(self, label, parentTag=None): self.label = label how can add the "parent" r...
I'm writing detailed functional tests for my views to complement the unit tests on my models. It's a Django project and I'm using the built in Django test framework with unittest. Obviously, one of the important things to check in these functional tests is that the permissions are set up correctly. With that in mind, I'm attempting somet...
Let's consider 3 situations: 1) I write a pyhon module in Eclipse (pydev) and run it Ctrl-F11. The module runs and I don't have any control or access (AFAIK) to the module variables and functions. 2) I have defined a python interpreter as an external tool in Eclipse, so I can run it within Eclipse. It works fine, but it does not have t...
Thank you all for helping. Below this post I put the corrected version's of both scripts which now produce the equal output. Hello, I have written a little brute string generation script in python to generate all possible combinations of an alphabet within a given length. It works quite nice, but for the reason I wan't it to be fast...
Is it possible to define a recursive list comprehension in Python? Possibly a simplistic example, but something along the lines of: nums = [1, 1, 2, 2, 3, 3, 4, 4] willThisWork = [x for x in nums if x not in self] # self being the current comprehension Is anything like this possible? ...