Are python built-in methods available in an alternate namespace?

Are python built-in methods available for reference in a package somewhere?

Let me explain. In the early (ier) days of python, I made a django model similar to this:

class MyModel(models.Model): first_name = models.CharField(max_length=100, null=True, blank=True) last_name = models.CharField(max_length=100, null=True, blank=True) property = models.ForeignKey("Property") 

Since then I need to add a property to it. This leaves me with this model:

 class MyModel(models.Model): first_name = models.CharField(max_length=100, null=True, blank=True) last_name = models.CharField(max_length=100, null=True, blank=True) property = models.ForeignKey("Property") @property def name(self): return "{} {}".format(first_name, last_name) 

So now at runtime I get an error: TypeError: 'ForeignKey' object is not callable . This is because the ForeignKey property for the property has replaced the built-in identifier property. What I would like to do is use @sys.property (or something similar) instead of @property .

Note. I already know about a workaround for moving the name property over the declaration of the property field. I am not very concerned about this particular case, as I am the main question of alternative places to link to python built-in modules.

+6
python built-in
source share
1 answer

Use __builtin__ .

 def open(): pass import __builtin__ print open print __builtin__.open 

This gives you:

 <function open at 0x011E8670> <built-in function open> 
+14
source share

All Articles