Ilias Lazaridis wrote:
> I have some python code which looks similar to this:
>
> class Car(BaseClass) :
>manufacturer = factory.string()
>model = factory.string()
>modelYear = factory.integer()
>
>def __str__(self):
>return '%s %s %s' % (self.modelYear,
Alex Martelli wrote:
> Vijairaj R <[EMAIL PROTECTED]> wrote:
>...
> > class Test:
>
> do not use old-style classes: they exist ONLY for backwards
> compatibility.
>
> Make you class Test new-style:
>
> class Test(object):
>...
>
>
> and you can call Test.__subclasses__() to get a list of a
Vijairaj R wrote:
> Hi,
> I have a requirement to findout all the classes that are derived from a
> single base class.
>
> This is how I do it currently.
>
> class Test:
> case = []
>
> class Test1(Test):
> Test.case.append("Test1")
>
> class Test2(Test):
> Test.case.append("Test2")
>
calmar wrote:
> On 2006-02-18, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
> > - why are these {{{ thingies there?
>
> markers for folding for vim
> http://www.calmar.ws/tmp/sc.png
I would look into one of the many Vim scripts which automatically fold
most large blocks without the ugly {{{.
--
> def lowest(s1,s2):
> s = ""
> for c1,c2 in [x for x in zip(s1,s2)]:
> s += lowerChar(c1,c2)
> return s
>
> but it's hardly any more elegant than using a loop counter, and I'm
> guessing it's performance is a lot worse - I assume that the zip
> operation is extra work?
>
> Iain
John Salerno wrote:
> I assume this is the way for loops are written in C, but if it helps to
> be specific, I'm referring to C# for loops. The Python for loop seems to
> be the same (or similar) to C#'s foreach loop:
>
> foreach int i in X
>
> But how would you write a C# for loop in Python? Do y
Woops! Thanks for the correction. I was assuming greediness for some
reason.
Fredrik Lundh wrote:
> Dylan Moreland wrote:
>
> > So I would try something like:
> >
> > pat = re.compile(r" (?:AND|OR|AND NOT) ")
> > pat.split(string)
>
> footnote: this y
Take a look at:
http://docs.python.org/lib/node115.html#l2h-878
So I would try something like:
pat = re.compile(r" (?:AND|OR|AND NOT) ")
pat.split(string)
Compile the regular expression with re.IGNORECASE if you like.
Nico Grubert wrote:
> Dear Python users,
>
> I'd like to split a string wher
No problem. There are, in fact, ugly class-based methods of doing this.
You could assign to an instance's __dict__ dictionary, or -- if the
class is a new-style class -- you can call the __setattr__(self, name,
value) method.
--
http://mail.python.org/mailman/listinfo/python-list
Take a look at the built-in function setattr:
http://ftp.python.org/doc/lib/built-in-funcs.html#l2h-64
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> nope didn't work
Could you be more specific about the error? Both my example and yours
work perfectly on my box.
--
http://mail.python.org/mailman/listinfo/python-list
I think you want to use the replace method of the string instance.
Something like this will work:
# See http://docs.python.org/lib/string-methods.html#l2h-196
txt = "an unfortunate in the middle"
txt = txt.replace("", "")
--
http://mail.python.org/mailman/listinfo/python-list
Radek Kubicek wrote:
> > What editor shall I use if my Python script must contain utf-8
> > characters?
> > I use XP
>
> vim :-)
>
> > Thank you for reply
> > l.b.
>
> not for all :-)
I myself have just begun using vim. Does anyone have any
tips/convenient tweaks for python programming with it?
Michael Spencer wrote:
> Dylan Moreland wrote:
> > I'm trying to implement a bunch of class methods in an ORM object in
> > order to provide functionality similar to Rails' ActiveRecord. This
> > means that if I have an SQL table mapped to the class "Person&quo
I'm trying to implement a bunch of class methods in an ORM object in
order to provide functionality similar to Rails' ActiveRecord. This
means that if I have an SQL table mapped to the class "Person" with
columns name, city, and email, I can have class methods such as:
Person.find_by_name
15 matches
Mail list logo