using reverse in list of tuples

2010-06-09 Thread james_027
hi, I am trying to reverse the order of my list of tuples and its is returning a None to me. Is the reverse() function not allow on list containing tuples? Thanks, James -- http://mail.python.org/mailman/listinfo/python-list

Re: fast regex

2010-05-06 Thread james_027
On May 6, 11:33 pm, John Bokma wrote: > james_027 writes: > > I was working with regex on a very large text, really large but I have > > time constrained. Does python has any other regex library or string > > manipulation library that works really fast? > > Hard to

Re: fast regex

2010-05-06 Thread james_027
On May 6, 11:33 pm, John Bokma wrote: > james_027 writes: > > I was working with regex on a very large text, really large but I have > > time constrained. Does python has any other regex library or string > > manipulation library that works really fast? > > Hard to

Re: fast regex

2010-05-06 Thread james_027
On May 6, 11:33 pm, John Bokma wrote: > james_027 writes: > > I was working with regex on a very large text, really large but I have > > time constrained. Does python has any other regex library or string > > manipulation library that works really fast? > > Hard to

fast regex

2010-05-06 Thread james_027
hi, I was working with regex on a very large text, really large but I have time constrained. Does python has any other regex library or string manipulation library that works really fast? Thanks, James -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing words in HTML file

2010-04-29 Thread james_027
On Apr 29, 5:31 am, Cameron Simpson wrote: > On 28Apr2010 22:03, Daniel Fetchinson wrote: > | > Any idea how I can replace words in a html file? Meaning only the > | > content will get replace while the html tags, javascript, & css are > | > remain untouch. > | > | I'm not sure what you tried and

replacing words in HTML file

2010-04-28 Thread james_027
hi, Any idea how I can replace words in a html file? Meaning only the content will get replace while the html tags, javascript, & css are remain untouch. THanks, James -- http://mail.python.org/mailman/listinfo/python-list

sorting a list of list

2007-11-20 Thread james_027
hi, are there available library or pythonic algorithm for sorting a list of list depending on the index of the list inside the list of my choice? d_list = [ ['a', 1, 9], ['b', 2, 8], ['c', 3, 7], ['d', 4, 6], ['e', 5, 5], ] Thanks james -- http://mail.python.org/mailman/list

PDF library

2007-11-15 Thread james_027
hi, I am looking for a python PDF library that starts with 'Q' ... I just found them somewhere in the internet but I can't find them now that I need it. Does someone knows this? Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: transforming list

2007-10-23 Thread james_027
hi, On Oct 24, 1:14 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Oct 23, 9:46?pm, james_027 <[EMAIL PROTECTED]> wrote:> hi, > > > i have a list from a resultset like this > > 1,&quo

transforming list

2007-10-23 Thread james_027
hi, i have a list from a resultset like this 1,"Chicago Bulls",,,"" 2,"Cleveland Caveliers",,,"" 4,"Detroit Pistons",1,"23686386.35" 4,"Detroit Pistons",2,"21773898.07" 4,"Detroit Pistons",3,"12815215.57" 4,"Detroit Pistons",4,"48522347.76" 4,"Detroit Pistons",5,"28128425.99" 4,"Detroit Pistons",6

calling a function from string

2007-10-22 Thread james_027
hi, i have a function that I could like to call, but to make it more dynamic I am constructing a string first that could equivalent to the name of the function I wish to call. how could I do that? the string could might include name of the module. for example a_string = 'datetime.' + 'today()'

Re: regex with specific list of string

2007-09-26 Thread james_027
Hi all, > This is fine IMO since the OP didn't specify the opposite. > Thanks for all your replies, though I don't understand quite well the going argument? What do you mean when you say "the OP didn't specify the opposite"? There reason for using regex is because I am going to use it in Django'

regex with specific list of string

2007-09-26 Thread james_027
hi, how do I regex that could check on any of the value that match any one of these ... 'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec' Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: %s shortcut?

2007-09-25 Thread james_027
hi bjorn, > You could do [year]*12 + [order_by] like so: > > >>> [1970] * 12 + ['foo'] > > [1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, 1970, > 1970, 'foo'] > > > > I don't know which database you're using, but the above doesn't look > like SQL'92... > Thanks, it works! I am using

%s shortcut?

2007-09-25 Thread james_027
hi i have something like this cursor.execute(""" select c.name, (select from ap_invoice i where Month(i.date) = 1 and Year(i.date) = %s and i.customer_id = c.id and i.status != 'CAN') jan, (select from ap_invoice i where Month(i.date) = 2 and Year(i.date

mass editing for keys in a dictionary

2007-09-14 Thread james_027
hi, How could I transform something like this dict_1 = {'customer_id':1, 'item_id':3, amount:100} into dict_2 = {'customer':1, 'item':3, amount:100} thanks james -- http://mail.python.org/mailman/listinfo/python-list

setattr vs readonly property

2007-09-12 Thread james_027
hi, My main purpose for using setattr(object, attr, value) for assign values from a dict that has some keys that may not be present on some object's attibute, which makes it work for me. My problem is dealing with read only attribute like sample_attribute = property(f_get=_get_sample_attribute). w

creating a dictionary from a dictionary with regex

2007-08-22 Thread james_027
Hi, I am trying to create a dictionary from a dictionary which the help of regex to identify which keys to select. I have something like this but I feel its long and not the fastest solution ... could someone contribute? import re d= {'line2.qty':2, 'line3.qty':1, 'line5.qty':12, 'line2.item':'5

Re: for statement on empty iterable

2007-08-21 Thread james_027
hi, > Oh I see. You have to combine a couple of concepts but for this > example you'd say: > >name = 'james' # 'l' looks too much like the digit 1 >for i,c in enumerate(name): > print i, c >print i > > enumerate(name) generates the sequence > >(0,'j'), (1,'a'), (2,'m'),

Re: for statement on empty iterable

2007-08-21 Thread james_027
hi, > It sounds like you're just starting to learn the language... have you > read the online tutorial yet? That is a pretty easy introduction. > > See:http://python.org/doc/ > > Anyway, you can say > >for i in (1,2,3): > print i*5 > > to print 5, 10, and 15 on separate lines, for examp

Re: for statement on empty iterable

2007-08-21 Thread james_027
hi Paul, > > That doesn't crash or anything like that, but it also doesn't > set the index variable, which can cause confusion in some situations. Thanks for your quick answer ... Actually I was thinking how do I access the index inside a for statement? Can you help Thanks james -- http://mai

for statement on empty iterable

2007-08-21 Thread james_027
hi, I need to do some for loop on iterables which could be empty sometimes, for example a_list = [] for i in a_list: #do something is this safe? or should I put a if statement to test it first? Thanks james -- http://mail.python.org/mailman/listinfo/python-list

searching dict key with reqex

2007-08-21 Thread james_027
hi, can I use regex instead of a plain string with this kind of syntax ... 'name' in a_dictionary something like r'name_\D+' in a_dictionary? Thanks james -- http://mail.python.org/mailman/listinfo/python-list

to property or function in class object

2007-08-16 Thread james_027
hi, i am very new to python, not knowing much about good design. I have an object here for example a Customer object, where I need to retrieve a info which has a number of lines of code to get it. my question is weather what approach should I use? to use the property which is from the python new

accessing keys in dict

2007-08-14 Thread james_027
hi, a_dict = {'name':'apple', 'color':'red', 'texture':'smooth', 'shape':'sphere'} is there any difference between .. for key in a_dict: from for key in a_dict.keys(): which is more preferred? any difference in performance? THanks james -- http://mail.python.org/mailman/listinfo/python-li

accessing static attributes

2007-08-09 Thread james_027
hi, for example an request object ... is request.user the same as request.__class__.user? THanks james -- http://mail.python.org/mailman/listinfo/python-list

help with flexible decorators

2007-08-06 Thread james_027
Hi, I want to write a flexible decorators to edit a function that may have 1 or more arguments... def enhance(func): def new(x): #do something ... return func(x) return new @enhance def method_a(x): #do something ... While the enhance decorator work with functions of

Re: a dict trick

2007-08-02 Thread james_027
Hi, what if we're not dealing with dict? is there a pythonic way of doing ternary? the bool ? x:y Thanks james -- http://mail.python.org/mailman/listinfo/python-list

a dict trick

2007-08-01 Thread james_027
hi for example I have this dictionary dict = {'name':'james', 'language':'english'} value = 'sex' in dict and dict['sex'] or 'unknown' is a right pythonic of doing this one? I am trying to get a value from the dict, but if the key doesn't exist I will provide one. THanks james -- http://mail

Re: access the name of my method inside it

2007-08-01 Thread james_027
Hi all! Thanks for all your idea, this community is truly a great one! james -- http://mail.python.org/mailman/listinfo/python-list

Re: access the name of my method inside it

2007-08-01 Thread james_027
Hi, On Aug 1, 5:18 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > On Wed, 01 Aug 2007 09:06:42 +, james_027 wrote: > > for example I have this method > > > def my_method(): > > # do something > > > # how do I get the name o

access the name of my method inside it

2007-08-01 Thread james_027
Hi, for example I have this method def my_method(): # do something # how do I get the name of this method which is my_method here? Thanks, james -- http://mail.python.org/mailman/listinfo/python-list

cls & self

2007-07-25 Thread james_027
hi, is cls & self the same thing? I have seen something like class A: def dosomething(cls): #doing something How is cls & self differ? How is it use? Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethod & staticmethod

2007-07-24 Thread james_027
hi, > The 'real' use is (are) the one(s) you'll find. FWIW, I use > staticmethods for helper functions that don't need access to the class > or instance but are too specific to a class to be of any use as plain > functions. Which is not a very frequent case. Classmethods are more > usefull - mostl

classmethod & staticmethod

2007-07-23 Thread james_027
hi, python's staticmethod is the equivalent of java staticmethod right? with classmethod, I can call the method without the need for creating an instance right? since the difference between the two is that classmethod receives the class itself as implicti first argument. From my understanding cla

Re: decorators tutorials

2007-07-23 Thread james_027
Hi, > > def check_login(func): > > def _check_login(*args): > > print "I am decorator" > > return func(*args) > > return _check_login > > > @check_login > > def method2(input): > > print "I am method TWO. Input %s" % input > > That looks okay. What is unclear? > It jus

Re: decorators tutorials

2007-07-23 Thread james_027
): #... def my_func(toto, tata): #... #call it like this check_login('msg') my_func('toto', 'tata') Thanks james On Jul 23, 6:26 pm, Bruno Desthuilliers wrote: > james_027 a écrit : > > > Hi all, > > > I am having difficulty understanding decorator.

Re: decorators tutorials

2007-07-23 Thread james_027
func(*args) return _check_login @check_login def method2(input): print "I am method TWO. Input %s" % input james On Jul 23, 4:41 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > james_027 wrote: > > Hi, > > > I am learning python by learning djang

decorators tutorials

2007-07-23 Thread james_027
Hi, I am learning python by learning django, and I stumble upon decorator which is very cool, any beginners resources for python decorators, although I can google it, I just want to get a good tutorial for this topic. Thanks james -- http://mail.python.org/mailman/listinfo/python-list

class attributes & data attributes

2007-06-20 Thread james_027
hi everyone, I am now in chapter 5 of Dive Into Python and I have some question about it. From what I understand in the book is you define class attributes & data attributes like this in python class Book: total # is a class attribute def __init__(self): self.title # is a data

python website

2007-06-20 Thread james_027
hi, what are you list of favorite python website (news, articles, tutorials)? cheers, james -- http://mail.python.org/mailman/listinfo/python-list

for web application development

2007-06-14 Thread james_027
hi everyone, I am very new to python, I am almost done learning the python language enough that I can start learning developing web app in python. I have gone thru many research and I still say that I will want to develop web app in python. Although some says php should be better since the languag

Dive into Python 5.5

2007-06-13 Thread james_027
Hi, class UserDict: def __init__(self, dict=None): self.data = {} if dict is not None: self.update(dict) I just don't understant this code, as it is not also mention in the book. the update is a method of a dict right? in my understanding the last statement should be self.data

Re: excel library without COM

2007-06-05 Thread james_027
On Jun 5, 6:17 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jun 5, 1:04 pm, james_027 <[EMAIL PROTECTED]> wrote: > > > > > On Jun 4, 8:16 pm, John Machin <[EMAIL PROTECTED]> wrote: > > > > On Jun 4, 3:52 pm, yuce <[EMAIL PROTECTED]> wr

Re: excel library without COM

2007-06-04 Thread james_027
On Jun 4, 8:16 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Jun 4, 3:52 pm, yuce <[EMAIL PROTECTED]> wrote: > > > i think this one works pretty nice:http://www.python.org/pypi/xlrd > > Sure does :-) However the "rd" in "xlrd" is short for "ReaD". As > Waldemar suggested, "xlwt" ("wt" as in WriTe

excel library without COM

2007-06-03 Thread james_027
Hi, is there any library to help me write excel files without using win com? because i'll be working on linux platform. At the same time I could want to perform some formatting, merging of cells. adding sheets and etc ... Thanks james -- http://mail.python.org/mailman/listinfo/python-list

Re: gui application on cross platform

2007-05-28 Thread james_027
On May 28, 3:06 pm, Stefano Canepa <[EMAIL PROTECTED]> wrote: > On 28 Mag, 08:01, james_027 <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I am using delphi to develop gui application, and wish to make a shift > > to python. here are some of my question/co

gui application on cross platform

2007-05-27 Thread james_027
Hi, I am using delphi to develop gui application, and wish to make a shift to python. here are some of my question/concern... 1. is python develop gui application a cross platform? just like java swing? 2. delphi makes things easy for me like coding for a specific event on a specific component, c