Python: object identity question?
>>>a=123>>>b=123>>>a is bTrue>>>id(a)==id(b)TrueMy question is, why is id(a) the same as id(b)?. Aren't they two different instances of class int? ...
>>>a=123>>>b=123>>>a is bTrue>>>id(a)==id(b)TrueMy question is, why is id(a) the same as id(b)?. Aren't they two different instances of class int? ...
I want to add an 'enclosure' custom field to an existing Wordpress post using Python & XML-RPC. My code looks like this: def add_enclosure(server, post_id, enclosure): post_data = server.metaWeblog.getPost(post_id, username, password) custom_fields = post_data['custom_fields'] new_id = max([int(field['id']) for field in cus...
Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way? Thanks, Boda Cydo. ...
Hello, I am using python 2.5 on Ubuntu, and there's a machine in the same network called "machine1". I wish to get a file in a specific folder of that machine. The folder is shared. So, how can I do it? I thought that something like urllib.urlopen('\machine1\folder\file.txt') would work. ...
I have an interesting genetics problem that I would like to solve in native Python (nothing outside the standard library). This in order for the solution to be very easy to use on any computer, without requiring the user to install additional modules. Here it is. I received 100,000s of DNA sequences (up to 2 billion) from a 454 new gene...
I am trying to automate the creation of something like this: <input type='text' name='asdf[]' /> <input type='text' name='asdf[]' /> <input type='text' name='asdf[]' /> By cycling through a range in the form. I've been trying things like this, along with several other variations: # in a model class for i in range(1, prim+1): self...
I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need...
I'm trying a simple program to send some html down a socket to a client. 2 things are goofing me up. The code: c.send( str.encode("<HTML><BODY>Test Page<///BODY><///HTML>") ) My python client receives: b'<HTML><BODY>Test Page<///BODY><///HTML>' According to Beginning Python which says it covers Python 3 (I'm using 3.1.1 on Window...
I compiled a simple hello world C module for Python and it works correctly in everything I've tried but IDLE. Here's what I type to test it: >>> import hello >>> hello.say_hello('Justin') I have tried this using Python from the command prompt(I'm using Windows), in Eclipse's PyDev, and with PieDream and they all print out Hello Justin...
I am working with DNA sequences of length 25 (see examples below). I have a list of 230,000 and need to look for each sequence in the entire genome (toxoplasma gondii parasite) I am not sure how large the genome is but much more that 230,000 sequences. I need to look for each of my sequences of 25 characters example(AGCCTCCCATGATTGAACAG...
The django admin allows you to specify fieldsets. You properly structure a tuple that groups different fields together. You can also specify classes for certain groups of fields. One of those classes is collapse, which will hide the field under a collapsable area. This is good for hiding rarely used or advanced fields to keep the UI clea...
I have made an update on Google App Engine with a small fix and I got: Closing update: new version is ready to start serving. However, when I open the website, there is still old version. I have changed version to 2 in app.yaml, before running update. What am I missing? ...
hi, can I do this in a loop, by producing the file name from the name of the array to store ? ab = array.array('B', map( operator.xor, a, b ) ) f1 = open('ab', 'wb') ab.tofile(f1) f1.close ac = array.array('B', map( operator.xor, a, c ) ) f1 = open('ac', 'wb') ac.tofile(f1) f1.close ad = array.array('B', map( operator.xor, a, d ) ) f1 ...
I'm writing a script to navigate a text-based menu system, using python's telnetlib to access a serial connection. I can happily press the F-keys, using the escape codes. e.g. F9 = "\033OX", where "\033" is the escape sequence. How do I encode the "esc" keyboard key? I would have expected just "\033", but that doesn't seem to work. ...
I'm configuring a new Developing Server that came with Windows 7 64bits. It must have installed Trac with Subversion integration. I install Subversion with VisualSVN 2.1.1, clients with TortoiseSVN 1.6.7 and AnkhSVN 2.1.7 for Visual Studio 2008 SP1 integration. All works fine! my problem begun when going to Trac installation. I insta...
Hey all. I have a question on how to implement the following with Django. I'd like to display a tabular view of my objects with each column corresponding to a particular model field. I'd like to be able to have the user sort the columns or search through all of them. Basically just like the admin, but client facing and read-only. It's si...
Hi, I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred? Thank you Bala Update I am still confused. Please help. Better in my sense means: 1. Bug will be fixed periodically. 2. Chosen by most developers. 3. Additional features like authentication tokens like AWS...
For the below models: class Customer(models.Model): id = models.IntegerField(primary_key=True) class OrderA(models.Model): name = models.CharField(max_length=20) foo = models.FloatField() customer = models.ForeignKey(Customer) type = models.IntegerField() class OrderB(models.Model): name = models.CharField(max_...
I'm trying to understand how python 2.5 deals with unicode strings. Although by now I think I have a good grasp of how I'm supposed to handle them in code, I don't fully understand what's going on behind the scenes, particularly when you type strings at the interpreter's prompt. So python pre 3.0 has two types for strings, namely: str (...
I have two models,Design and Profile. Profile is hooked up in settings.py as the profile to be used with the User model. So I can access it via user.get_profile(). And each Design instance has an author property that is a ForeignKey to User. So, when I'm any view, I can get the screenname (a property of Profile) by: user.get_profile()...