On Monday, May 21, 2012 9:39:59 AM UTC-4, Jon Clements wrote:
> > def experience_text(self):
> > return dict(CHOICES).get("self.level", "???")
> Haven't used django in a while, but doesn't the model provide a
> get_experience_display() method which you could use...
Duh, I totally mi
On Monday, 21 May 2012 13:37:29 UTC+1, Roy Smith wrote:
> I've got this code in a django app:
>
> CHOICES = [
> ('NONE', 'No experience required'),
> ('SAIL', 'Sailing experience, new to racing'),
> ('RACE', 'General racing experience'),
> ('GOOD', 'Experienced
On 05/21/12 08:10, Steven D'Aprano wrote:
> On Mon, 21 May 2012 08:37:29 -0400, Roy Smith wrote:
>
> [...]
>> The above code works, but it occurs to me that I could use the much
>> shorter:
>>
>> def experience_text(self):
>> return dict(CHOICES).get("self.level", "???")
>>
>> So, the
One suggestion is to construct the dictionary first:
CHOICES = dict(
NONE = 'No experience required',
SAIL = 'Sailing experience, new to racing',
RACE = 'General racing experience',
GOOD = 'Experienced racer',
ROCK = 'Rock star'
)
def experience_text(self):
try:
On Mon, 21 May 2012 08:37:29 -0400, Roy Smith wrote:
[...]
> The above code works, but it occurs to me that I could use the much
> shorter:
>
> def experience_text(self):
> return dict(CHOICES).get("self.level", "???")
>
> So, the question is, purely as a matter of readability, which
On Mon, May 21, 2012 at 10:37 PM, Roy Smith wrote:
> The above code works, but it occurs to me that I could use the much
> shorter:
>
> def experience_text(self):
> return dict(CHOICES).get("self.level", "???")
>
> So, the question is, purely as a matter of readability, which would you
>
I've got this code in a django app:
CHOICES = [
('NONE', 'No experience required'),
('SAIL', 'Sailing experience, new to racing'),
('RACE', 'General racing experience'),
('GOOD', 'Experienced racer'),
('ROCK', 'Rock star'),
]
def experience_
tuxagb:
> If I have to write an extension module with many objects, how can I
> organizing the code?
> I think: every object in a separate file, and a last file with the
> PyInit_. function. But is unmenageable .
>
> Solutions?
What do you think about using Cython?
Bye,
bearophile
--
htt
If I have to write an extension module with many objects, how can I
organizing the code?
I think: every object in a separate file, and a last file with the
PyInit_. function. But is unmenageable .
Solutions?
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list