Re: property using a classmethod

2009-07-09 Thread Bruno Desthuilliers
Lie Ryan a écrit : Emanuele D'Arrigo wrote: (snip) Ultimately all I want is a non-callable class-level attribute MyClass.myProperty that gives the result of MyClass.myClassMethod(). This works like what you seem to want (it's ugly): Ugly, indeed. And an extreme case of arbitrary overcomplex

Re: property using a classmethod

2009-07-09 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Greetings, today I did something like this: class MyClass(object): @classmethod def myClassMethod(self): Usually, the first argument of classmethods is named 'cls' print "ham" myProperty = property(myClassMethod, None, None) As many of

Re: [0, 0, 0, 1, 1, 1, 0] ... remove all 0 values

2009-07-08 Thread Bruno Desthuilliers
Daniel Austria a écrit : Hi python - hackers, just one question. How can i remove all 0 values in a list? Sure - i can loop over it, but that s not a neat style. list.remove() will only remove the first occurence. Doing that while no exception is raised is also uncool, right? Some suggestions?

Re: Why re.match()?

2009-07-07 Thread Bruno Desthuilliers
Paul Rudin a écrit : Bruno Desthuilliers writes: kj a écrit : In <4a4e2227$0$7801$426a7...@news.free.fr> Bruno Desthuilliers writes: kj a écrit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism,

Re: Why re.match()?

2009-07-07 Thread Bruno Desthuilliers
kj a écrit : In <4a4e2227$0$7801$426a7...@news.free.fr> Bruno Desthuilliers writes: kj a écrit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism, FWIW, Python has no pretention to minimalism. As

Re: A Bug By Any Other Name ...

2009-07-07 Thread Bruno Desthuilliers
Daniel Fetchinson a écrit : Yes, there are plenty of languages other than Java and C, but the influence of C is admittedly huge in Python. Why do you think loops are called "for", conditionals "if" or "while", functions return via "return", loops terminate via "break" and keep going via "continue

Re: A Bug By Any Other Name ...

2009-07-07 Thread Bruno Desthuilliers
Daniel Fetchinson a écrit : (snip) and my point is that users are most of time correct when they assume that something will work the same way as in C. Oh, really ? They would surely be wrong if they'd expect the for loop to have any similarity with a C for loop, or - a *very* common error - if

Re: a little wsgi framework

2009-07-07 Thread Bruno Desthuilliers
timmyt a écrit : i'm interested in getting opinions on a small wsgi framework i assembled from webob, sqlalchemy, genshi, and various code fragments i found on the inter-tubes here is the interesting glue - any comments / suggestions would be much appreciated Well... My first comment would be

Re: How Python Implements "long integer"?

2009-07-06 Thread Bruno Desthuilliers
Mark Dickinson a écrit : On Jul 5, 1:09 pm, Pedram wrote: Thanks for reply, Sorry I can't explain too clear! I'm not English ;) That's shocking. Everyone should be English. :-) Mark, tu sors ! -- http://mail.python.org/mailman/listinfo/python-list

Re: try -> except -> else -> except?

2009-07-06 Thread Bruno Desthuilliers
Python a écrit : (snip whole OP) as far as I know try has no 'else' Then you may want to RTFM. -- http://mail.python.org/mailman/listinfo/python-list

Re: try -> except -> else -> except?

2009-07-06 Thread Bruno Desthuilliers
David House a écrit : Hi all, I'm looking for some structure advice. I'm writing something that currently looks like the following: try: except KeyError: else: This is working fine. However, I now want to add a call to a function in the `else' part that may raise an exception, s

Re: Why re.match()?

2009-07-03 Thread Bruno Desthuilliers
kj a écrit : (snipo To have a special-case re.match() method in addition to a general re.search() method is antithetical to language minimalism, FWIW, Python has no pretention to minimalism. -- http://mail.python.org/mailman/listinfo/python-list

Re: Clarity vs. code reuse/generality

2009-07-03 Thread Bruno Desthuilliers
kj a écrit : I'm will be teaching a programming class to novices, and I've run into a clear conflict between two of the principles I'd like to teach: code clarity vs. code reuse. I'd love your opinion about it. (snip - others already commented on this code) Here's the rub: the code above is

Re: Adding an object to the global namespace through " f_globals" is that allowed ?

2009-07-03 Thread Bruno Desthuilliers
Stef Mientki a écrit : hello, I need to add an object's name to the global namespace. The reason for this is to create an environment, where you can add some kind of math environment, where no need for Python knowledge is needed. The next statement works, but I'm not sure if it will have any dr

Re: Python debugger

2009-07-03 Thread Bruno Desthuilliers
srinivasan srinivas a écrit : Hi, Could you suggest some python debuggers? http://docs.python.org/library/pdb.html#module-pdb HTH -- http://mail.python.org/mailman/listinfo/python-list

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Scott David Daniels a écrit : (snip) And even simpler: PASSWORD = "qwerty" MAXRETRY = 3 for attempt in range(MAXRETRY): if raw_input('Enter your password: ') == PASSWORD: print 'Password confirmed' break # this exits the for loop print 'Access

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
Charles Yeomans a écrit : Please don't top-post (not corrected) Let me offer a bit of editing. First, using the condition count != 3 is perhaps risky. A mistake or a change in logic in the loop body might result in an infinite loop. So instead I suggest while count < 3... Second, I'd su

Re: Getting input the scanf way

2009-07-01 Thread Bruno Desthuilliers
Mr.SpOOn a écrit : Hi, I need to do some kind of interactive command line program. I mean: I run the program, it asks me for input, I type something and then I get the output or other questions. I'm not sure what is the right way to achieve this. Simplest : use raw_input() Friendlier (at least

Re: Basic question from pure beginner

2009-07-01 Thread Bruno Desthuilliers
sato.ph...@gmail.com a écrit : Thank you for all of the help. With your assistance and help from the Python Tutor mailing list I was able to come up with the following code: password = "qwerty" correct_password_given = False guess = "0" You could just use None here: guess=None count = 0

Re: Learning to use decorators with classes

2009-07-01 Thread Bruno Desthuilliers
sk8in_zo...@yahoo.com.au a écrit : --- On Tue, 30/6/09, Bruno Desthuilliers wrote: (snip) This can't work, and it's a FAQ FWIW - but since there's no official c.l.py FAQ, we won't hold it against you !-) Can you please point me to the FAQ related to this snippet.

Re: Learning to use decorators with classes

2009-06-30 Thread Bruno Desthuilliers
Mr SZ a écrit : Hi, I'm writing an LDAP plugin for my TG2 application. In this I wrote a small class based decorator with args to set up a connection and call the necessary functionality but I'm having problems with it. Here's my code: (snip code) class LdapPlugin(Plugin): ... def _

Re: Specific iterator in one line

2009-06-30 Thread Bruno Desthuilliers
Chris Rebert a écrit : (snip) reduce(lambda x,y:x+y,({1:['b']*2,0:['a']}[z] for z in [1, 0, 0, 1])) ['b', 'b', 'a', 'a', 'b', 'b'] 69 chars long (plus or minus how the input list is written). You can save 4 more characters using tumple dispatch instead of dict dispatch: reduce(lambda x,y :

Re: seeking thru a file

2009-06-26 Thread Bruno Desthuilliers
Mag Gam a écrit : I have a compressed CSV gziped file. Then gunzip it first... I was wondering if it is possible to seek thru a file For example: I want to load the first 100 lines into an array. Process the data Seek from 101 line to 200 lines. Process the data (remove lines 0 - 100) from

Re: Inheritance and forward references (prototypes)

2009-06-22 Thread Bruno Desthuilliers
Dave Angel a écrit : (snip Default arguments of class methods are evaluated during the definition of the class Default arguments of functions are eval'd during the execution of the def statement. The fact that you use a def statement within a class statement's body is totally orthogonal -

Re: Inheritance and forward references (prototypes)

2009-06-22 Thread Bruno Desthuilliers
Piet van Oostrum a écrit : Steven D'Aprano (SD) wrote: (snip) SD> # A.__base__ = DebugA ## Uncomment this line for debugging. A.__base__ = DebugA TypeError: readonly attribute Make that: A.__bases__ = DebugA, or even better (readability-wise): A.__bases__ = (DebugA,) Just the sam

Re: Missing c.l.py posts (was Re: A question on scope...)

2009-06-22 Thread Bruno Desthuilliers
Aahz a écrit : In article <4a3b5dc3$0$2985$426a7...@news.free.fr>, Bruno Desthuilliers wrote: NB : answering the OP (original post didn't show up on c.l.py ???) Correct. There's a problem with the mail->news gateway, I think that MIME messages are failing. I &quo

Re: Decorator question (how to test if decorated function is in a class)

2009-06-19 Thread Bruno Desthuilliers
Martin P. Hellwig a écrit : Hi all, I have been trying out to wrap my mind around the advantages of decorators and thought I found a use in one of my experiments. (see code after my sig). Although it works, I think it should be able to do it better. My particular problem is that I want to re

Re: generator expression works in shell, NameError in script

2009-06-19 Thread Bruno Desthuilliers
Emile van Sebille a écrit : On 6/17/2009 3:54 PM ssc said... Wow! Didn't expect that kind of instant support. Thank you very much, I'll give both zip and enumerate a try. The code I've shown is actually copied pretty straight from a Django form class, but I didn't want to mention that as not to

Re: A question on scope...

2009-06-19 Thread Bruno Desthuilliers
MRAB a écrit : Wells Oliver wrote: NB : answering the OP (original post didn't show up on c.l.py ???) In writing out python classes, it seems the 'self' is optional, You mean, inside a method ? meaning that inside a class method, In Python, a "class method" is a method that operates on

Re: Regarding Python is scripting language or not

2009-06-18 Thread Bruno Desthuilliers
Asun Friere a écrit : (snip) OTOH the whole notion of defining OO by the use of classes automatically excludes from consideration prototype-based OO languages (eg. Self) which arguably offer a purer approach to OO than class centric languages. FWIW, there's no notion of "class" in the minimal

Re: Question about None

2009-06-17 Thread Bruno Desthuilliers
John Yeung a écrit : On Jun 13, 2:29 am, Steven D'Aprano wrote: Paul LaFollette wrote: 3) (this is purely philosophical but I am curious) Would it not be more intuitive if isinstance(None, ) returned true? Good grief no!!! None is an object. It has a type, NoneType. It's *not* a string, or a

Re: class or instance method

2009-06-17 Thread Bruno Desthuilliers
Paul Johnston a écrit : Hi, I would like to have a method that is both a classmethod and an instancemethod. So: class MyClass(object): @class_or_instance def myfunc(cls_or_self): pass The semantics I'd like are: When you call MyClass.myfunc, it gets passed a class When you call MyClass

Re: Question about None

2009-06-12 Thread Bruno Desthuilliers
Paul LaFollette a écrit : Kind people, Using Python 3.0 on a Gatesware machine (XP). I am building a class in which I want to constrain the types that can be stored in various instance variables. This somehow goes against the whole philosophy of dynamic typing Python is based upon... But ther

Re: Access from a class attribute

2009-06-04 Thread Bruno Desthuilliers
Kless a écrit : Why can not to access from a class attribute to a function of that class? - class Foo(object): attr = __class__.__name__ attr = self.__class__.__name__ - "class" is an executable statement that instanciate a new class object and bind it t

Re: How does Python's OOP feel?

2009-05-27 Thread Bruno Desthuilliers
Ikon a écrit : I'm rather new to Python. I have PHP for my main language and I do some Java. They all have a very strict OO schema. I would describe PHP's "OO schema" as "very strict" (FWIW, I wouldn't qualify anything PHP as "strict" in any way...) As I red through Python's tutorial it sea

Re: What text editor is everyone using for Python

2009-05-27 Thread Bruno Desthuilliers
Rhodri James a écrit : On Tue, 26 May 2009 14:22:29 +0100, Roy Smith wrote: My pet peeve is syntax-aware editors which get things wrong. For example, the version of emacs I'm using now doesn't parse this properly: '''A triple-quoted string. Some editors won't get this right''' The solutio

Re: Are Python-based web frameworks reliable enough?

2009-05-26 Thread Bruno Desthuilliers
Gilles Ganault a écrit : Hello Until now, the modest web apps I wrote were all in PHP because it's available on just about any hosted server. I now have a couple of ideas for applications where I would deploy my own servers, so that I'd rather write them in Python because I find the lan

Re: Just wondering

2009-05-15 Thread Bruno Desthuilliers
Gediminas Kregzde a écrit : Hello, I'm Vilnius college II degree student and last semester our teacher introduced us to python I've used to program with Delphi, so I very fast adopted to python Now I'm developing cross platform program and use huge amounts of data. Program is needed to run as f

Re: introspection question: get return type

2009-05-15 Thread Bruno Desthuilliers
Aahz a écrit : In article <4a0c6e42$0$12031$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Marco Mariani a écrit : Bruno Desthuilliers wrote: Oh, you meant the "return type" ? Nope, no way. It just doesn't make sense given Python's dynamic typing. Unless he&#

Re: When *don't* I use 'self' in classes?

2009-05-14 Thread Bruno Desthuilliers
Tim Chase a écrit : (snip) try: self.ser = Serial() self.ser.baudrate = DEFAULT_BAUD self.ser.open() except SomeSpecificException: print "Fail!" Please make it: try: self.ser = Serial() self.ser.baudrate = DEFAULT_BAUD sel

Re: introspection question: get return type

2009-05-14 Thread Bruno Desthuilliers
Marco Mariani a écrit : Bruno Desthuilliers wrote: Oh, you meant the "return type" ? Nope, no way. It just doesn't make sense given Python's dynamic typing. I thought that the OP was writing a tool to document not-very-dynamic code. Unless he's really trying

Re: introspection question: get return type

2009-05-14 Thread Bruno Desthuilliers
flam...@gmail.com a écrit : Hello, I am wondering if it's possible to get the return value of a method *without* calling it Getting the return *value* without calling the function ? heck, that would be really helpful - we'd save quiet a lot on function call overhead and function execution tim

Re: python copy method alters type

2009-05-14 Thread Bruno Desthuilliers
Zhenhai Zhang a écrit : Really weired; Here is my code: a = ["a", 1, 3, 4] print "a:", a c = copy(a) c[0] = "c" c[1] = 2 print "c:", c print "a:",a output as follows: a: ['a', 1, 3, 4] c: ['c' '2' '3' '4'] a: ['a', 1, 3, 4] Btw, I'm using python 2.5. I'm very curious wh

Re: dict would be very slow for big data

2009-05-12 Thread Bruno Desthuilliers
forrest yang a écrit : hi i am trying to insert a lot of data into a dict, which may be 10,000,000 level. after inserting 10 unit, the insert rate become very slow, 50,000/ s, and the entire time used for this task would be very long,also. would anyone know some solution for this case? Hint

Re: Why there is a parameter named "self" for classmethod function?

2009-05-11 Thread Bruno Desthuilliers
Terry Reedy a écrit : Kurt Symanzik wrote: But you might consider decorating the method as a static method instead since in your example you are not using the parameter at all. A static method would not require a parameter. @staticmethod def print_hello(): print "hello" Functions th

Re: Code - what could be done better?

2009-05-11 Thread Bruno Desthuilliers
Florian Wollenschein a écrit : Hi all, here's the main code of thc, my txt to html converter. Since I'm a beginner it is far, far, faaar away from perfect or even good :-) What could be done better? (snip code) 1/ decouple the text => html conversion part from your (or any other) GUI 2

Re: Which one is best Python or Java for developing GUI applications?

2009-05-05 Thread Bruno Desthuilliers
Paul Rubin a écrit : srinivasan srinivas writes: Could you tell me does Python have any advantages over Java for the development of GUI applications? Yes. Indeed. -- http://mail.python.org/mailman/listinfo/python-list

Re: Personal recommendations for Python and Django on-boarding materials

2009-05-05 Thread Bruno Desthuilliers
Arnaud Delobelle a écrit : Grant Rettke writes: Hi folks, From one developer to another, I am looking for some personal recommendations on what are the best materials for fast tracking an on- boarding to Python and Django. I know how to program, get web apps and OO; this is the audience. I

Re: Python Noob - a couple questions involving a web app

2009-04-30 Thread Bruno Desthuilliers
David Smith a écrit : Kyle T. Jones wrote: (snip question and answers recommending Django) Thanks everyone! Wow, pretty much a consensus - a rarity with these "types" of questions, at least in my experience. >> Ok, sounds like I need to be looking at Django. Thanks for the advice! Cheers

Re: dict is really slow for big truck

2009-04-30 Thread Bruno Desthuilliers
forrest yang a écrit : i try to load a big file into a dict, which is about 9,000,000 lines, something like 1 2 3 4 2 2 3 4 3 4 5 6 How "like" is it ?-) code for line in open(file) arr=line.strip().split('\t') dict[arr[0]]=arr but, the dict is really slow as i load more data into the m

Re: dict is really slow for big truck

2009-04-30 Thread Bruno Desthuilliers
bearophileh...@lycos.com a écrit : Sion Arrowsmith: The keys aren't integers, though, they're strings. You are right, sorry. I need to add an int() there. Which is not garanteed to speed up the code FWIW -- http://mail.python.org/mailman/listinfo/python-list

Re: dict is really slow for big truck

2009-04-29 Thread Bruno Desthuilliers
bearophileh...@lycos.com a écrit : On Apr 28, 2:54 pm, forrest yang wrote: i try to load a big file into a dict, which is about 9,000,000 lines, something like 1 2 3 4 2 2 3 4 3 4 5 6 code for line in open(file) arr=line.strip().split('\t') dict[line.split(None, 1)[0]]=arr but, the dict

Re: Pythonic emptiness checking

2009-04-29 Thread Bruno Desthuilliers
Filip Gruszczyński a écrit : One of the Python Zen rules is Explicit is better implicit. And yet it's ok to do: if x: do_sth when x is string or list. Since it's very comfy, I've got nothing against though. I am just curious, why is it so? Because it is explicit (or at least considered as

Re: Why bool( object )?

2009-04-29 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message <54cb7f8a- fef4-4bf8-8054-16dc9b5c8...@d2g2000pra.googlegroups.com>, Aaron Brady wrote: What is the rationale for considering all instances true of a user- defined type? It's a stupid idea, Nope, it's a very sensible default (given you can redefine

Re: Python Noob - a couple questions involving a web app

2009-04-29 Thread Bruno Desthuilliers
Kyle T. Jones a écrit : Been programming for a long time, but just starting out with Python. Not a professional programmer, just that guy in one of those organizations that won't hire a pro, instead saying "Hey, Kyle knows computer stuff - let's have him do this (and that, and the other, etc)".

Re: Introducing Python to others

2009-03-26 Thread Bruno Desthuilliers
Paddy O'Loughlin a écrit : (snip) Anything else you think could make PHP developers starting think that python is a better choice? The debugger ?-) (debugging PHP code is kind of nightmare). If I were to do a (very) short demonstration one web framework for the PHP devs, what should I use? Ch

Re: Python 3 consistency proposal

2009-03-25 Thread Bruno Desthuilliers
Ben Finney a écrit : Steven D'Aprano writes: If you *are* willing to do the work, the chances would still be pretty slim. Guido has just rejected a patch adding PEP 8 compliant aliases for types like datetime […] As Guido has quoted before, "A foolish consistency is the hobgoblin of little min

Re: Does __init__ of subclass need the same argument types as __init__ of base class?

2009-03-25 Thread Bruno Desthuilliers
Sibylle Koczian a écrit : (snip) I don't understand at all why I get the same message with this little script: import datetime class meindatum(datetime.date): def __init__(self, datum): print "meindatum" datetime.date.__init__(self, datum.year,

Re: Is python worth learning as a second language?

2009-03-21 Thread Bruno Desthuilliers
Aahz a écrit : In article <49b5196b$0$3514$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Grant Edwards a écrit : Knowing C++ does tend to be a bit of a handicap, but I think any competent programmer could learn Python. +2 QOTW !-) Ditto! Although I suppose you could just go f

Re: Another of those "is" issues.

2009-03-21 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Hi everybody, I was unit testing some code today and I eventually stumbled on one of those "is" issues quickly solved replacing the "is" with "==". Still, I don't quite see the sense of why these two cases are different: def aFunction(): ... pass ... f = aFunc

Re: Can I rely on...

2009-03-20 Thread Bruno Desthuilliers
Emanuele D'Arrigo a écrit : Hi everybody, I just had a bit of a shiver for something I'm doing often in my code but that might be based on a wrong assumption on my part. Do not assume. Either check or use another solution. My 2 cents... Take the following code: pattern = "aPattern" compile

Re: Do deep inheritance trees degrade efficiency?

2009-03-19 Thread Bruno Desthuilliers
Chris Rebert a écrit : On Wed, Mar 18, 2009 at 6:09 AM, Anthra Norell wrote: Would anyone who knows the inner workings volunteer to clarify whether or not every additional derivation of a class hierarchy adds an indirection to the base class's method calls and attribute read-writes. In C++, I s

Re: Smalltalk-like Python IDE ?

2009-03-18 Thread Bruno Desthuilliers
Lobo a écrit : Hi, My experience has been with Smalltalk using Object databases. I would very much appreciate your recommendations on a Python IDE closest to the Smalltalk 'image' environment, with class browsers, implementors/senders, inspectors, debuggers, etc. Well, Python is file-based, n

Re: split problem if the delimiter is inside the text limiter

2009-03-18 Thread Bruno Desthuilliers
rewonka a écrit : (snip) Now i stucked when i tried to pu into db. Because i have some cell that is in somekind of unicoded text, You mean "encoded in something else than utf8" ? and i'm looking a solution how to put this into db (my db in utf-8 format). (snip) but something binary in a c

Re: split problem if the delimiter is inside the text limiter

2009-03-18 Thread Bruno Desthuilliers
Tim Chase a écrit : sql = ''' INSERT INTO table (column1,column2, ...) VALUES ( %s, %s, ); ''' for row in rows: connection.cursor.execute(sql % (row[0],row[1],)) connection.corsur.commit() (snip) The first step is to use the database's quoting to prevent problems where miscreant

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
John Posner a écrit : (My apologies if the thread has already covered this.) I believe I understand the WHAT in this situation, but I don't understand the WHY ... Given this class definition: class Cls(object): x = 345 ... I observe the following, using IDLE 2.6.1: inst = Cls() Cls.x is inst

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
Rhodri James a écrit : On Sun, 15 Mar 2009 17:55:25 -, Aaron Brady wrote: On Mar 15, 12:39 pm, John Posner wrote: (snip) Is there a beneficial effect of silently creating the instance attribute, which outweighs the detrimental effects: (1) inconsistency, (2) the "surprising" decoupli

Re: Style question - defining immutable class data members

2009-03-15 Thread Bruno Desthuilliers
Maxim Khitrov a écrit : On Sat, Mar 14, 2009 at 2:07 PM, Gary Herron wrote: Maxim Khitrov wrote: Very simple question on the preferred coding style. I frequently write classes that have some data members initialized to immutable values. For example: class Test(object): def __init__(self):

Re: Python/Django forum-building software Snap/SCT, any reviews?

2009-03-13 Thread Bruno Desthuilliers
John Crawford a écrit : I'm looking for good open-source software for forums. There is a *lot* out there, for instance Lussumo's Vanilla gets good reviews, but most are PHP-based, and I would obviously prefer to use Python, with or without Django. Two packages that are Django-based that I have

Re: Question on periods in strings

2009-03-12 Thread Bruno Desthuilliers
Philip Bloom a écrit : (snip) from datetime import datetime startTime = datetime.now() (snip) print (datetime.now() - startTime) A bit OT, but you may want to use timeit.Timer for this kind of microbenchmarks. (snip) -- http://mail.python.org/mailman/listinfo/python-list

Re: elixir vs. storm

2009-03-11 Thread Bruno Desthuilliers
Dan Barbus a écrit : Hi, Anyone here compared elixir with storm? Both are sqlite declarative wrappers (as far as I understood) and both seem to hide the (unnecessary for what I want) SQL/data layer under pythonic wrappers. elixir is a declarative layer over SQLAlchemy, which is a hi-level SQL

Re: Is python worth learning as a second language?

2009-03-09 Thread Bruno Desthuilliers
Tomasz Rola a écrit : (snip) I may not be objective (tried Java, hated it after 6 years). Arf - only took me 6 months !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is python worth learning as a second language?

2009-03-09 Thread Bruno Desthuilliers
David Cournapeau a écrit : On Mon, Mar 9, 2009 at 11:33 PM, grocery_stocker wrote: On Mar 9, 5:30 am, Nick Craig-Wood wrote: Go here http://www.diveintopython.org/ Download the PDF or buy the book. What about the stuff on docs.python.org? Isn't that information just as reliable? They d

Re: Is python worth learning as a second language?

2009-03-09 Thread Bruno Desthuilliers
Grant Edwards a écrit : (snip) Knowing C++ does tend to be a bit of a handicap, but I think any competent programmer could learn Python. +2 QOTW !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Is python worth learning as a second language?

2009-03-09 Thread Bruno Desthuilliers
ZikO a écrit : Hi I hope I won't sound trivial with asking my question. I am a C++ programmer and I am thinking of learning something else because I know second language might be very helpful somehow. Indeed. FWIW, I use about four programming languages on a daily basis - plus "non-programm

Re: This should be a simple question...

2009-03-06 Thread Bruno Desthuilliers
Neal Becker a écrit : Maybe I'm missing something obvious here def A (...): #set a bunch of variables x = 1 b = 2 ... Do something with them def B (...): #set the same bunch of variables x = 1 b = 2 ... Do something with them I want to apply DRY, and extract out the common se

Re: Can Python do shopping cart?

2009-03-06 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : On Thu, 5 Mar 2009 14:30:54 -0800 (PST), Muddy Coder declaimed the following in comp.lang.python: I know PHP can do shopping cart, such as Zen Cart. I wonder can Python do such a thing? Thanks! Python is a general purpose, byte-code-compiled/interpreted, l

Re: Help required to read and print lines based on the type of first character

2009-03-06 Thread Bruno Desthuilliers
abhinayaraj.r...@emulex.com a écrit : (snip) I need to have a look at that all those doc's you have mentioned. That should help. +1 QOTW !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3 on the Web

2009-03-05 Thread Bruno Desthuilliers
Johannes Permoser a écrit : Hi, I wanted to learn Python from scratch and start off with Version 3. Since I already know PHP very well, I thought it would be nice to start off with a small web-project. But what's the way to bring python3 to the Web? mod_python isn't available, cgi is said to be

Re: Help required to read and print lines based on the type of first character

2009-03-05 Thread Bruno Desthuilliers
abhinayaraj.r...@emulex.com a écrit : Please, don't top-post, and learn to quote & snip (if you don't know what top-posting is, google is your friend). Thank you so much for your guidance, Bruno. This should help me in a long way. Here is the code I have written. path = raw_input("\nEnter

Re: Help required to read and print lines based on the type of first character

2009-03-05 Thread Bruno Desthuilliers
(answering to the OP) En Wed, 04 Mar 2009 07:36:01 -0200, escribió: I am a beginner in Python. In fact, beginner to coding/ scripting. Here is a scenario, I need to code. Need your help on this: Your first task here should be to refine the specs - too much ambiguities in it: A script th

Re: String Identity Test

2009-03-05 Thread Bruno Desthuilliers
Avetis KAZARIAN a écrit : > Well, it's not about curiosity, it's more about performance. Steve Holden wrote: (snip) So, don't try to translate concepts from one language to another. I'll try ;] Also and FWIW: 1/ Python has some very handy tools when it comes to perfs - like a couple pr

Re: String Identity Test

2009-03-05 Thread Bruno Desthuilliers
Hendrik van Rooyen a écrit : "S Arrowsmith" wrote: "Small" integers get a similar treatment: a = 256 b = 256 a is b True a = 257 b = 257 a is b False This is weird - I would have thought that the limit of "small" would be at 255 - the biggest number to fit in a byte. 256 takes two byt

Re: Server programming

2009-03-04 Thread Bruno Desthuilliers
koranthala a écrit : On Mar 3, 8:09 pm, Bruno Desthuilliers wrote: koranthala a écrit : (snip) Hi Bruno, After reading your email, I tried reworking my code so that most of my logic moves to Models. But, most probably because this is my first application development, I am unable to do

Re: looking for template package

2009-03-04 Thread Bruno Desthuilliers
Neal Becker a écrit : I'm looking for something to do template processing. That is, transform text making various substitutions. I'd like to be able to do substitutions that include python expressions, to do arithmetic computations within substitutions. I know there are lots of template pac

Re: Server programming

2009-03-03 Thread Bruno Desthuilliers
koranthala a écrit : (snip) Hi Bruno, After reading your email, I tried reworking my code so that most of my logic moves to Models. But, most probably because this is my first application development, I am unable to do so. For example: I have Models A,B, C, D . Now, there is not muc

Re: Multiple conditional expression

2009-03-02 Thread Bruno Desthuilliers
Steve Holden a écrit : Anjanesh Lekshminarayanan wrote: How do we know that from the what the OP posted? Its CGI alright. spaces = form.has_key('spaces') and form.getvalue('spaces') == '1' But I just dont see how spaces = (form.has_key('spaces') ? form.getvalue('spaces') == 1 ? True: False : F

Re: String search

2009-02-27 Thread Bruno Desthuilliers
pranav a écrit : Greeting fellow pycoders, I have a script that browses large codes and replaces certain text with some other text. Of lately i observed an issue.Some of the original text were like ,N'#attributes.SOFTPREREQ#' My module does scan this code and suggests replacement to this

Re: Delete all items in the list

2009-02-26 Thread Bruno Desthuilliers
Clarendon a écrit : Hi. This must be a simple command but I just can't find it in the Phthon manual. How do I delete all items with a certain condition from a list? For instance: L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'. Ho

Re: python sql query in django

2009-02-25 Thread Bruno Desthuilliers
May a écrit : On Feb 24, 10:36 am, "Diez B. Roggisch" wrote: Thanks for all your suggestions. From what I've experienced in Django and now that I know a little more about how Python functions, I will probably use a combination of PHP and Django, instead of trying to get Python to do the web po

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Robin Becker a écrit : well this sort of awful hackery will allow you to put read only constants on an existing module (snip example code) so I guess if you write your own module class and then use a special importer you can create module like objects with read only attributes. Fine tec

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Ethan Furman a écrit : Steve Holden wrote: Brian Allen Vanderburg II wrote: (snip) One idea to make constants possible would be to extend properties to be able to exist at the module level as well as the class level: @property def pi(): return 3.14159. print(pi) # prints 3.14159 p

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Brian Allen Vanderburg II a écrit : bock...@virgilio.it wrote: Constants would be a nice addition in python, sure enough. But I'm not sure that this can be done without a run-time check every time the constant is used, and python is already slow enough. Maybe a check that is disabled when runn

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Ben Finney a écrit : (snip - about using ALL_CAPS for pseudo-constants) Perhaps I'd even argue for an update to PEP 8 that endorses this as conventional. +1 I've been a bit surprised last time I checked PEP8 to find out this wasn't already the case - I would have sweared it was. -- http://ma

Re: pep 8 constants

2009-02-25 Thread Bruno Desthuilliers
Brendan Miller a écrit : PEP 8 doesn't mention anything about using all caps to indicate a constant. Is all caps meaning "don't reassign this var" a strong enough convention to not be considered violating good python style? I see a lot of people using it, but I also see a lot of people writing n

Re: python sql query in django

2009-02-23 Thread Bruno Desthuilliers
May a écrit : (snip) I may not stay with Django. Nope, but your question was about Django. I am seriously looking for whether python can read data from a relational database Of course - as long as there's a Python adapter for your DB. and send to an html template Of course - as long as

Re: Server programming

2009-02-23 Thread Bruno Desthuilliers
koranthala a écrit : Hi, Is server programming in Python procedure oriented or object oriented? It's how you want it to be. I have this question because lately I am asked to make a medium complex web program (extremely database oriented) using Django. When I used to do application

Re: python sql query in django

2009-02-23 Thread Bruno Desthuilliers
May a écrit : I have three tables: Actually - from Python's code POV - three Model classes. And actually, since there's a very active, friendly and helpful django group on googlegroups, you'd be better reposting your question there. (snip Django's ORM related question) -- http://mail.python

Re: How do I declare global vars or class vars in Python ?

2009-02-20 Thread Bruno Desthuilliers
Paddy O'Loughlin a écrit : 2009/2/20 Bruno Desthuilliers : Interesting. Why shouldn't you? I haven't used the property() function s/function/object/ Nice try, but what I wrote was what I intended to say: http://docs.python.org/library/functions.html#property Check by yourse

Re: How do I declare global vars or class vars in Python ?

2009-02-20 Thread Bruno Desthuilliers
Paddy O'Loughlin a écrit : 2009/2/20 Bruno Desthuilliers : Note that while you *can* do direct access to the implementation attribute (here, '_A' for property 'A'), you don't *need* to so (and usually shouldn't - unless you have a very compelling reason).

<    1   2   3   4   5   6   7   8   9   10   >