Re: CONTEST - What is the (best) solution?

2005-02-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : In a file there can be several dictionaries like this (snip) I need to read only the the first and the last dictionaries.What is a best solution? Depends on your definition of 'best solution'. -- http://mail.python.org/mailman/listinfo/python-list

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-03 Thread Bruno Desthuilliers
Daniel Bickett a écrit : This is certainly a worthy topic. There are several IDEs for Python (one I like very much being Komodo) that have plenty of fancy debugging features and advanced operations, however I have yet to encounter (elsewhere) the convenience that comes with being able to press F5

Re: IDLE history, Python IDE, and Interactive Python with Vim

2005-02-03 Thread Bruno Desthuilliers
Pierre Barbier de Reuille a écrit : Fuzzyman a écrit : If you use IPython for your interactive mode stuff, you'll have a nice history... Regards, Fuzzy http://www.voidspace.org.uk/python/index.shtml Best event : if your EDITOR system variable in vim, using the ed command in ipython will bring vim

Re: sos!

2005-02-05 Thread Bruno Desthuilliers
jordan2856977 a écrit : hellow everybody! I'm from china. I'm a beginner of python. in china, python is not a fashionable language, so it's difficult to find some books about python. finally,I find a book named python how to program wrote by H.M.Deitel . who can tell me where can I find some

Re: who can tell me BASICS of Python

2005-02-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I want to know which compiler I can use ... thank you To compile what ? Python code ? The compiler is in the standard lib. -- http://mail.python.org/mailman/listinfo/python-list

Re: Error!

2005-02-05 Thread Bruno Desthuilliers
Steve Holden a écrit : (snip) So, for example, your program might look like this: base_price = int(raw_input(...)) tax_rate = int(raw_input(...) tax_amount = base_price * ((100+tax_amount)/...) s/(100+tax_amount)/(100 + tax_rate)/, I guess ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Definitive documentation on newstyle classes? (WAS: Pickling and inheritance are making me hurt)

2005-02-05 Thread Bruno Desthuilliers
Daniel Bickett a écrit : I was reading the Pickling and inheritance are making me hurt thread, and the latest suggestion (as of this posting) was to do with the __setstate__ and __getstate__ methods. They caught my attention because I hadn't encountered them before, and it reminded me that in the

Re: Loop in list.

2005-02-08 Thread Bruno Desthuilliers
Jim a écrit : Where did this type of structure come from: mat = ['a' for i in range(3)]? This will produce a list of three elements but I don't see reference for it in any of the books. Now everyone told you *what* is it, I'll (very very dumbly) answer the question : this syntax comes from

Re: [N00B] What's %?

2005-02-10 Thread Bruno Desthuilliers
administrata a écrit : Hi! it's been about a week learning python! I've read 'python programming for the absolute begginer' I don't understand about % like... 107 % 4 = 3 7 % 3 = 1 it's the modulo operator (if you don't remember, the modulo is the remaining of the integer division, ie 5 % 2 = 1)

Re: goto, cls, wait commands

2005-02-10 Thread Bruno Desthuilliers
Duncan Booth a écrit : BOOGIEMAN wrote: (snip) Secondly, how do I clear screen (cls) from text and other content ? That depends on your computer, and how you are running your program. One way which *might* work is: import os os.system(cls) *might* work... !-) [EMAIL PROTECTED] modulix $ cls

Re: goto, cls, wait commands

2005-02-10 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2005-02-10, BOOGIEMAN [EMAIL PROTECTED] wrote: First of all, what's Python command equivalent to QBasic's goto ? There isn't one. One defines functions and calls them. One uses for and while loops. One uses list comprehensions. One uses if/elif/else. and even

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Bruno Desthuilliers
jfj a écrit : bruno modulix wrote: Ilias Lazaridis wrote: I'm a newcomer to python: [EVALUATION] - E01: The Java Failure - May Python Helps? http://groups-beta.google.com/group/comp.lang.python/msg/75f0c5c35374f553 My trollometer's beeping... When person 'A' calls person 'B' a troll, these are

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-14 Thread Bruno Desthuilliers
Stephen Kellett a écrit : In message [EMAIL PROTECTED], Simon Brunning [EMAIL PROTECTED] writes On Mon, 14 Feb 2005 14:12:57 +0100, bruno modulix [EMAIL PROTECTED] wrote: Why do you hate Perl and Ruby community that much ? Oh, I don't. But fair's fair - we've carried our share of the burden,

Re: DHTML control from Python?

2005-02-14 Thread Bruno Desthuilliers
Kenneth McDonald a écrit : In article [EMAIL PROTECTED], aurora [EMAIL PROTECTED] wrote: What are the win 32 modules? Searching OS X win 32 on Google gave me a bit too much... I guess Aurora did not took time to read your whole post. Win32 modules are for Windows, of course... --

Re: regular expression question

2005-02-14 Thread Bruno Desthuilliers
snacktime a écrit : The primary question is how do I perform a match when the regular expression contains string variables? For example, in the following code I want to match a line that starts with STX, then has any number of characters, then ends with STX. Example 2 I'm pretty sure works as I

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-15 Thread Bruno Desthuilliers
Ilias Lazaridis a écrit : bruno modulix wrote: Ilias Lazaridis wrote: (snip) impressive. but things are much simpler. Could you be more prolific ? Please explain the word prolific. Say more -- http://mail.python.org/mailman/listinfo/python-list

Re: Variables.

2005-02-15 Thread Bruno Desthuilliers
Jeff Shannon a écrit : bruno modulix wrote: administrata wrote: I wrote this, It's a bit lame though (snip code - see other answers in this thread) raw_input(\n\\t\t\t- The End -) Why on earth are you using raw_input() here ? This is a fairly common idiom, on Windows at least. Windows only, I

Re: Popularity of blogging tools used by python programmers

2005-10-20 Thread Bruno Desthuilliers
Stewart Midwinter a écrit : I've made a comparison of the relative popularity of blogging tools used by python programmers. I was surprised by the number of python developers not using python for their blogs; isn't that like GM employees driving Toyota cars? See my post at:

Re: Setting Class Attributes

2005-10-25 Thread Bruno Desthuilliers
the.theorist a écrit : I have a small, simple class which contains a dictionary (and some other stuff, not shown). I then have a container class (Big) that holds some instances of the simple class. When I try to edit the elements of the dictionary, all instances obtain those changes; I want

Re: security

2005-10-25 Thread Bruno Desthuilliers
Mattia Adami a écrit : Hi to all. I'm intristing in write a plugin for browsers that can execute python code. I know the main problem is security. Many thread were opened about this in the ng. I would know if fork python rewriting some library could avoid problems. I.e. one problem is the

Re: assignment to reference

2005-10-26 Thread Bruno Desthuilliers
Loris Caren a écrit : If a = 'apple' b = 'banana' c = 'cabbage' How can I get something like:- for i in 'abc': r = eval(i) if r == 'cabbage': r = 'coconut' actually change the object referenced by r rather than creating a new object temporarily referenced by it?

Re: How to replace all None values with the string Null in a dictionary

2005-10-29 Thread Bruno Desthuilliers
dcrespo a écrit : I think it would be time for you to read the Fine Manual... hi, thanks for your answer... I really did it the same way you suggested, but I forgot to tell you that I wanted to get a better way for doing it. Let us know if you find one... By the way, knowing your

Re: expanding dictionary to function arguments

2005-11-02 Thread Bruno Desthuilliers
Noah a écrit : I have a dictionary that I would like to expand to satisfy a function's agument list. I can used the ** syntax to pass a dictionary, but this only works if each key in the dictionary matches an argument. I cannot pass a dictionary that has more keys than the function has

Re: when and how do you use Self?

2005-11-03 Thread Bruno Desthuilliers
Jeffrey Schwab a écrit : bruno at modulix wrote: Steven D'Aprano wrote: On Thu, 03 Nov 2005 10:14:23 +0100, bruno at modulix wrote: Tieche Bruce A MSgt USMTM/AFD wrote: I am new to python, Could someone explain (in English) how and when to use self? Don't use self. Use other. Are

Re: when and how do you use Self?

2005-11-03 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Thu, 03 Nov 2005 20:19:03 +0100, bruno at modulix wrote: Steven D'Aprano wrote: On Thu, 03 Nov 2005 10:14:23 +0100, bruno at modulix wrote: Tieche Bruce A MSgt USMTM/AFD wrote: I am new to python, Could someone explain (in English) how and when to use

Re: when and how do you use Self?

2005-11-07 Thread Bruno Desthuilliers
Tieche Bruce A MSgt USMTM/AFD a écrit : Well, thanx for all the ... useful information. I thought that I would try, but this has turned out to be a waist of my time. Have fun playing with your egos s/your egos/words/ If you can't stand a joke (possibly very bad, but that's another

Re: Diff. between Class types and classic classes

2005-11-08 Thread Bruno Desthuilliers
Colin J. Williams a écrit : bruno at modulix wrote: venk wrote: Hi, can some one properly explain the differences between class types and classic classes? ... Still face problems in identifying what is what. I'm not sure I understand your question. Are you talking about the diff

Re: derived / base class name conflicts

2005-11-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Your suggestion ('_name' - implementation, 'name' - API) This is not my convention, it's *the* (mostly agreed upon) Python convention. Like 'self', or CONSTANT, or a whole lot of things in Python. makes sense as a convention between programmers that know a fair

Re: Multikey Dict?

2005-11-12 Thread Bruno Desthuilliers
David Rasmussen a écrit : If I have a collection of dicts like: john = {'id': 1, 'name': John Cleese, 'year': 1939} graham = {'id': 2, 'name': Graham Chapman, 'year': 1941} I could store all of them in a list. But for easy lookup, I might store all these in a dict instead, like people

Re: Multikey Dict?

2005-11-12 Thread Bruno Desthuilliers
Sam Pointon a écrit : If I could just say to Python: john and graham (and ...) are all a part of a superdict and either their id or their name can be used as keys. Can I do that somehow? Sure you can. There are two obvious ways to do this - enlist the aid of a Superdict (or similar)

Re: Python Book

2005-11-13 Thread Bruno Desthuilliers
David Rasmussen a écrit : What is the best book for Python newbies (seasoned programmer in other languages)? I don't know if it's the best, but a DiveIntoPython/PythonCookbook combo may be a good choice. -- http://mail.python.org/mailman/listinfo/python-list

Re: Copyright [was Re: Python Obfuscation]

2005-11-13 Thread Bruno Desthuilliers
Erik Max Francis a écrit : David T wrote: Individuals, and perhaps groups of individuals are the creators of works. When someone pays you to create a work, then they own the copyright, Depends on the country's laws and the exact agreement. --

Re: Python obfuscation

2005-11-15 Thread Bruno Desthuilliers
The Eternal Squire a écrit : Without copyright, how could one possibly earn a living writing a novel? Without copyright, how could one possibly earn a living writing programs?-) -- http://mail.python.org/mailman/listinfo/python-list

Re: creating package question

2005-11-16 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I think I have an answer to my own question. In the WindowsComponents/__init__.py file, I have the following, that feels like a better answer for the problem. Is there a better answer than this? import os, sys sys.path.append(os.path.join(os.getcwd(),

Re: about try and exception

2005-11-19 Thread Bruno Desthuilliers
Shi Mu a écrit : On 11/17/05, Carl J. Van Arsdall [EMAIL PROTECTED] wrote: (Carl's top-post corrrected. Carl, please do not top-post) Ben Bush wrote: I wrote the following code to test the use of try...exception, and I want n to be printed out. However, the following code's output is:

Re: examining python objects

2005-11-19 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Is there a function/class/module/whatever I can use to look at objects? I want something that will print the object's value (if any) in pretty-printed form, and list all it's attributes and their values. And do all that recursively. I want to be able to find out

Re: Confused about namespaces

2005-11-19 Thread Bruno Desthuilliers
KvS a écrit : Ok, makes sense but didn't seem natural to me, It will seem more natural if you understand that modules should be modulars (ie: low coupling, high cohesion). A module should *never* bother about no rely upon other modules being imported by the module it imports itself. Err, not

Re: Is Python weak on the web side?

2005-11-20 Thread Bruno Desthuilliers
Tony a écrit : If I'd like to learn Python for web-development, what are the options available? There are too many *good* options for web developpement in Python. Thanks. tony -- http://mail.python.org/mailman/listinfo/python-list

Re: ownership problem?

2005-11-20 Thread Bruno Desthuilliers
Gabriel Zachmann a écrit : Is it correct to say that the typical ownership problem, which frequently arises in C++, does not occur normally in Python? What is this typical ownership problem ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Underscores in Python numbers

2005-11-20 Thread Bruno Desthuilliers
Raymond Hettinger a écrit : Gustav Hållberg wrote: I tried finding a discussion around adding the possibility to have optional underscores inside numbers in Python. This is a popular option available in several competing scripting langauges, that I would love to see in Python. Examples:

Re: Working with flat files [LDIF].

2005-01-05 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Scott A. McIntyre wrote: I looked around but didn't see any LDIF tools for perl or python... Any assistance or advice is appreciated!! Scott Hello Scott, Did you ever get this issue resolved? I have a similar need to merge two LDIF files. I did find a program called

Re: Getting rid of self.

2005-01-07 Thread Bruno Desthuilliers
BJörn Lindqvist a écrit : I think it would be cool if you could refer to instance variables without prefixing with self. I know noone else thinks like me so Python will never be changed, but maybe you can already do it with Python today? (snip code) It works! exec(magic()) does the needed hi =

Re: tuples vs lists

2005-01-08 Thread Bruno Desthuilliers
worzel a écrit : I get what the difference is between a tuple and a list, but why would I ever care about the tuple's immuutability? Because, from a purely pratical POV, only an immutable object can be used as kay in a dict. So you can use tuples for 'composed key'. Bruno --

Re: tuples vs lists

2005-01-10 Thread Bruno Desthuilliers
Antoon Pardon a écrit : Op 2005-01-08, Bruno Desthuilliers schreef [EMAIL PROTECTED]: worzel a écrit : I get what the difference is between a tuple and a list, but why would I ever care about the tuple's immuutability? Because, from a purely pratical POV, only an immutable object can be used

Re: Request opinion on web application framework

2005-12-04 Thread Bruno Desthuilliers
Thomas a écrit : Hello, I am new to web programming but have some experience in technical programming in Python and other languages. I need to build a networked program which I would like to first deploy on an intranet and later on the web which provides access to a few technical

Re: Another newbie question

2005-12-08 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : I'm off to study the code. (Hmm.. how does python parse (green, red)[(i * 8 + j) % 2] command ... (green, red)[0] == green (green, red)[1] == red (i * 8 + j) is somewhat trivial (just take care of precedence order), and will return an integer % is the modulo

Re: OO in Python? ^^

2005-12-11 Thread Bruno Desthuilliers
Matthias Kaeppler a écrit : Hi, sorry for my ignorance, but after reading the Python tutorial on python.org, I'm sort of, well surprised about the lack of OOP capabilities in python. I beg your pardon ??? Honestly, I don't even see the point at all of how OO actually works in Python.

Re: OO in Python? ^^

2005-12-11 Thread Bruno Desthuilliers
Matthias Kaeppler a écrit : (snip) I stumbled over this paragraph in Python is not Java, can anyone elaborate on it: In Java, you have to use getters and setters because using public fields gives you no opportunity to go back and change your mind later to using getters and setters. So

Re: Newbie with some doubts.

2006-01-09 Thread Bruno Desthuilliers
Edgar A. Rodriguez a écrit : Hi everybody, Im newbie to Python (I found it three weeks ago) , in fact Im newbie to programming. I'm being reading and training with the language, but I still wondering about what Classes are used to. A class is the definition of a type of object, and let you

Re: Help with dynamic attributes.

2006-01-09 Thread Bruno Desthuilliers
Mr.Rech a écrit : (snip) My class's init method takes a list of lists as input argument and I'd like to create several attributes each one referencing one item of the passed list. Easy-of-use arguments has led me to call these attributes as x0, x1, x2 and so on. This is a very wrong

Re: Django and SQLObject. Why not working together?

2005-09-08 Thread Bruno Desthuilliers
Ksenia Marasanova a écrit : 2005/9/8, Sokolov Yura [EMAIL PROTECTED]: Django Model is wonderfull. But SQLObject more flexible (and powerfull, as i think, and has already more db interfaces). But Django Model is tied with Django, and using Django with another OO mapping is not comfortable. Why

Re: Why do Pythoneers reinvent the wheel?

2005-09-11 Thread Bruno Desthuilliers
Stefano Masini a écrit : (snip) If such a quick and dirty section existed, I think it would also become a natural randevouz point for innovators. s/randevouz/rendez-vous/ !-) pardon-my-french-ly y'rs -- http://mail.python.org/mailman/listinfo/python-list

Re: How to protect Python source from modification

2005-09-12 Thread Bruno Desthuilliers
Frank Millman a écrit : bruno modulix wrote: Frank Millman wrote: Hi all I am writing a multi-user accounting/business system. Data is stored in a database (PostgreSQL on Linux, SQL Server on Windows). I have written a Python program to run on the client, which uses wxPython as a gui, and

Re: Inconsistent reaction to extend

2005-09-12 Thread Bruno Desthuilliers
Jerzy Karczmarczuk a écrit : Gurus, No guru answered, so you'll have to bear with me... before I am tempted to signal this as a bug, perhaps you might convince me that it should be so. If I type l=range(4) l.extend([1,2]) l gives [0,1,2,3,1,2], what else... On the other hand, try

Re: Python Doc Problem Example: os.path.split

2005-09-18 Thread Bruno Desthuilliers
Laszlo Zsolt Nagy a écrit : is the doc writer, trying to write the doc with some austereness, but is confused about the behavior of split, or confused about expressing it? Did his pretension fucked him up? Dear Xah Lee, The Python community is very sorry because we have a very bad

Re: functional or object-oriented?

2005-09-19 Thread Bruno Desthuilliers
beza1e1 a écrit : I see myself shifting more and more over to the functional kind of coding. Could be related to the Haskell, we had to learn in CS. Now i was wondering, how other people use Python? With functional i mean my files mostly consist of functions which is not enough to make it

Re: Removing Warning Messages .............

2005-09-19 Thread Bruno Desthuilliers
chand a écrit : Hi., In my api.py file 'g_opt_list' is defined globally g_opt_list =[[],[],[],[],[],[],[]] when I run the py file, I am getting the Following Error SyntaxWarning: name 'g_opt_list' is used prior to global declaration SyntaxWarning: name 'layers' is used prior to global

Re: very high-level IO functions?

2005-09-19 Thread Bruno Desthuilliers
York a écrit : (snip) I love python. However, as a biologist, I like some high-levels functions in R. I don't want to spend my time on parse a data file. http://www.python.org/doc/current/lib/module-csv.html Then in my python script, I call R to read data file and write them into an

Re: Newbie regular expression and whitespace question

2005-09-22 Thread Bruno Desthuilliers
googleboy a écrit : Hi. I am trying to collapse an html table into a single line. Basically, anytime I seewith nothing but whitespace between them, I'd like to remove all the whitespace, including newlines. I've read the how-to and I have tried a bunch of things, but nothing seems to

Re: Need to pass Object by value into a list

2005-09-26 Thread Bruno Desthuilliers
Aaron a écrit : I have a data sructure setup and I populate it in a loop like so: y=0 while X: DS.name = ASDF DS.ID = 1234 list[y] = DS; y = y + 1 print list Traceback (most recent call last): File stdin, line 1, in ? File /usr/tmp/python-9150sSF, line 2, in ?

Re: Carrying variables over from function to function

2005-09-26 Thread Bruno Desthuilliers
Ivan Shevanski a écrit : Alright heres my problem. . .Say I want to carry over a variable from one function to another or even another run of the same function. Is that possible? Heres a quick example of what I'm talking about. def abc(): x = 1 y = x + 1 print y def abcd():

Re: Which SQL module to use?

2005-10-04 Thread Bruno Desthuilliers
mrstephengross a écrit : I'd like to do some basic SQL stuff in Python. It seems like there are a heck of a lot of SQL modules for Python. What's the simplest and easiest one to use? Probably the one that go with your RDBMS. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's Performance

2005-10-09 Thread Bruno Desthuilliers
Laszlo Zsolt Nagy a écrit : Dave wrote: Hello All, I would like to gather some information on Python's runtime performance. As far as I understand, it deals with a lot of string objects. Does it require a lot string processing during program execution? How does it handle such

Re: override a property

2005-10-17 Thread Bruno Desthuilliers
Robin Becker a écrit : Is there a way to override a data property in the instance? Do I need to create another class with the property changed? Do you mean attributes or properties ? -- http://mail.python.org/mailman/listinfo/python-list

Re: __init__() not called automatically

2005-05-26 Thread Bruno Desthuilliers
Roy Smith a écrit : bruno modulix [EMAIL PROTECTED] wrote: I've always explicitelly used the (implied) 'this' pseudo-pointer in Java, C++ etc. The wart is in all those languages that don't makes it mandatory IMHO !-) And the correlary wart in Python is that the first argument to a method

Re: staticmethod and classmethod

2005-05-26 Thread Bruno Desthuilliers
C Gillespie a écrit : Hi, Does anyone know of any examples on how ( where) to use staticmethods and classmethods? Here's an example from a ldap lib (work in progress, not finished, and all other disclaimers). The class methods are here: #

Re: Self-modifying Code

2005-05-26 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : (snip) Having said that, here is a good example of self-modifying code: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68429 The RingBuffer class dynamically modifies itself once it is full so that its behaviour changes. This is nothing more than a

Re: Python Exercises for Newbee

2005-05-30 Thread Bruno Desthuilliers
Kanthi Kiran Narisetti a écrit : Hi ALL, I am Windows Administrator, moving little ahead from batch files and scripts I started learning Python. I found that Python is very easy and is very well documented. Still I am looking more than examples. As a beginner i want to do lot of excersice

Re: cgi help

2005-06-01 Thread Bruno Desthuilliers
nephish a écrit : Hey there, i am trying to write an online application using the cgi module. what i want to do is have an html form display a drop-down list and have the values of that list be the lines of text written in a file. Simplest, QD solution : 1/ open the file for reading 2/ print

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread Bruno Desthuilliers
infidel a écrit : Oh great, just when I thought I was starting to grok this mess. +1 dont-worry-no-normal-humain-brain-can-handle-this-kind-of-stuff-ly'yrs -- http://mail.python.org/mailman/listinfo/python-list

Re: metaclass that inherits a class of that metaclass?

2005-06-01 Thread Bruno Desthuilliers
Kristian Zoerhoff a écrit : On 1 Jun 2005 09:41:53 -0700, infidel [EMAIL PROTECTED] wrote: Why in the name of all that is holy and just would you need to do such a thing? Is anyone else amused that this came from the mouth of someone named Infidel? I was just recovering from a ROFL

Re: bug with isinstance() ?

2005-06-01 Thread Bruno Desthuilliers
Mac a écrit : Under certain circumstances isinstance() seems to return incorrect value for me. I'm using Python 2.3 (latest from Debian's unstable). Here's a sample program... the multi-module nature of the code is key. === test.py === class Foo: pass def test(): from

Re: How to get/set class attributes in Python

2005-06-12 Thread Bruno Desthuilliers
Chris Spencer a écrit : Kalle Anke wrote: On Sun, 12 Jun 2005 13:59:27 +0200, deelan wrote (in article [EMAIL PROTECTED]): void doSomething( data : SomeClass ){ ... } and I would be sure at compile time that I would only get SomeClass objects as parameters into the method. Being an

Re: How to test if an object IS another object?

2005-06-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : If two objects are of equal value you can compare them with ==. What I want to do is find out if two objects are actually just references to the same object, how can I do this in Python? The most obvious way (as usual ?): if obj1 is obj2: // your code here --

Re: How to get/set class attributes in Python

2005-06-12 Thread Bruno Desthuilliers
Chris Spencer a écrit : Bruno Desthuilliers wrote: And *this* is highly unpythonic. And un-OO too, since it makes foo() dependant on *class* Bar, when it should most probably be enough that it only depends on (probably part of) the *interface* of class Bar. I was providing the original

Re: How to test if an object IS another object?

2005-06-12 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Sorry about removing my message, I posted with the wrong google account, I don't really want my email where those irritating spam bots can find it. The most obvious way (as usual ?): if obj1 is obj2: // your code here I immediately thought of is, and

Re: What is different with Python ?

2005-06-13 Thread Bruno Desthuilliers
Andrea Griffini a écrit : (snip) What I know is that every single competent programmer I know (not many... just *EVERY SINGLE ONE*) started by placing firmly concrete concepts first, and then moved on higher abstractions (for example like structured programming, OOP, functional languages

Re: Controlling assignation

2005-06-13 Thread Bruno Desthuilliers
Xavier Décoret a écrit : (snip) What I wanted to do is something like this: def change(x,v): x = v class A(object): def __init__(self,v): self.x = v a = A(3) print a.x # displays 3 change(a.x,4) print a.x # still displays 3 It may seem weird, It does but

Re: Controlling assignation

2005-06-14 Thread Bruno Desthuilliers
Xavier Décoret a écrit : Bruno Desthuilliers a écrit : (snip) I really wonder what it can be ??? It's the ability to develop the equivalent of GeoNext (and much more) in Python with a very nice syntax. This is nice, but this does not explain the why of your code snippet. You could

Re: Inheriting from object

2005-06-29 Thread Bruno Desthuilliers
Fuzzyman a écrit : Hello, To create a classic (old style) class, I write : class foo: pass To do the equivalent as a new style class, I write : class foo(object): pass *Should* I in fact write : class foo(object): def __init__(self, *args, **kwargs):

Re: Seeking IDE

2005-06-30 Thread Bruno Desthuilliers
Nick Mountford a écrit : Hi, Complete newb to Python and programming, looking for an open source IDE to download. Any suggestions? Use something simple. Start with Idle (it comes with Python, and has all the basic features you may need to learn Python). When you'll have learn the bases, it

Re: Lost in a sea of documentation...can you point me in the right direction?

2005-06-30 Thread Bruno Desthuilliers
MooMaster a écrit : (snip) I'd like to write a program that I can pass a path to (say: My Pictures) and at a timer interval will pick a picture from it and set my wallpaper to that So I started reading about os, threads, and the path for the special folders What's a special folder ??? in

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Bruno Desthuilliers
Stian Søiland a écrit : (snip) Hey, I know! t = python.util.ImmutableArrayList.fromCollection(L.getAbstractCollection()) python.util.functional.applyFunctionOnCollection( (class implements python.util.functional.AnonymousFunction: def anonymousFunction(x):

Re: Should I use if or try (as a matter of speed)?

2005-07-09 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : My shot would be to test it like this on your platform like this: #!/usr/bin/env python import datetime, time Why not use the timeit module instead ? t1 = datetime.datetime.now() for i in [str(x) for x in range(100)]: A bigger range (at least 10/100x more)

Re: Defending Python

2005-07-09 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2005-07-09, Brian [EMAIL PROTECTED] wrote: folks as an easily acquired extra skill. I agree 100% with your statement above. Python may not be sufficient for being the only programming language that one needs to know -- yet, it does come in VERY handy for

Re: Defending Python

2005-07-10 Thread Bruno Desthuilliers
Jorey Bump a écrit : Bruno Desthuilliers [EMAIL PROTECTED] wrote in news:[EMAIL PROTECTED]: Grant Edwards a écrit : On 2005-07-09, Brian [EMAIL PROTECTED] wrote: folks as an easily acquired extra skill. I agree 100% with your statement above. Python may not be sufficient for being

Re: Help - Classes and attributes

2005-07-14 Thread Bruno Desthuilliers
rh0dium a écrit : Hi all, I believe I am having a fundamental problem with my class and I can't seem to figure out what I am doing wrong. Basically I want a class which can do several specific ldap queries. So in my code I would have multiple searches. But I can't figure out how to do it

Re: Help - Classes and attributes

2005-07-14 Thread Bruno Desthuilliers
rh0dium a écrit : Hi I really like your approach but when do you actually get connected?? You never call the method connect? oops :( (snip whole code) if __name__ == '__main__': truc = NSCLdap() truc.connect() # was missing truc.search() BTW, you'd better let exceptions

Re: Python and MySQL server

2005-07-14 Thread Bruno Desthuilliers
Unknown a écrit : Python 2.4 Linux kernel 2.6.12 Hi, 1. How do I make the following statement to search for all Strings I input from console? for example, with the code below I need to enter %hello world% (yeah, including the % symbols) to find all entries for hello world on the

Re: Printing a variable's name not its value

2005-07-20 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hey, I am trying to write a function that takes an arbitrary number of arguments and does one of two things. If the variable is a key in a dictionary, it prints the key and its value. Otherwise, if any of the variables isn't in the dictionary, the function

Re: Returning histogram-like data for items in a list

2005-07-21 Thread Bruno Desthuilliers
Ric Deez a écrit : Hi there, I have a list: L1 = [1,1,1,2,2,3] How can I easily turn this into a list of tuples where the first element is the list element and the second is the number of times it occurs in the list (I think that this is referred to as a histogram): i.e.: L2 =

Re: problem with string

2005-07-22 Thread Bruno Desthuilliers
Tzanko Tzanev a écrit : hi :) I need some help for this script I have please take care of indentation when posting code. cursor = conn.cursor() cursor.execute(select * from playlist limit 5) result = cursor.fetchall() # iterate through resultset playlist_txt = ''

Re: Getting a dictionary from an object

2005-07-23 Thread Bruno Desthuilliers
Thanos Tsouanas a écrit : Hello. I would like to have a quick way to create dicts from object, so that a call to foo['bar'] would return obj.bar. The following works, but I would prefer to use a built-in way if one exists. Is there one? Thanks in advance. class dictobj(dict):

Re: Separation of Code in CGI App

2005-07-23 Thread Bruno Desthuilliers
Rob Cowie a écrit : Hi, I need to create a planner/calendar system using python cgi scripts. It is my first CGI app (beyond a few tutorial examples). (snip) You may want to have a look at the cgi_app mini-framework: - http://thraxil.org/code/cgi_app/ It's a port of a Perl framework, and

Re: Getting a dictionary from an object

2005-07-23 Thread Bruno Desthuilliers
Thanos Tsouanas a écrit : On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote: use getattr(self.obj,key) possibly, as __getattribute__ gets total control on attribute access Thanks, but what do you mean by 'total control'? mode=screamin jay hawkins __getattribute__ is really some

Re: PostgreSQL Python vs PHP

2005-07-24 Thread Bruno Desthuilliers
Luis P. Mendes a écrit : (snip) I need to build it from the server and also client side. For the client side I'll be using Python. But for the server side, I would like to hear some opinions. Is it worth learning Php? I dont think so - unless you have no other choice !-) More

Re: Initializing interactive Python

2005-07-24 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : Hi all, is it possible to enter an interactive session and automatically do some initialization? I explain better: I want that when I start interactive Python on a console (I use Linux) two command lines be executed automatically: [EMAIL PROTECTED] bruno $ python

Re: Getting a dictionary from an object

2005-07-24 Thread Bruno Desthuilliers
Thanos Tsouanas a écrit : On Sun, Jul 24, 2005 at 01:43:43PM +1000, Steven D'Aprano wrote: (snip) Why jump through all those hoops to get attributes when Python already provides indexing and attribute grabbing machinery that work well? Why do you bother to subclass dict, only to mangle the

Re: Getting a dictionary from an object

2005-07-24 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : (snip) class Wrapper(object): def __init__(self, obj): self._obj = obj def __getitem__(self, name): return getattr(self._obj, name) If you want the Wrapper to be more like a Decorator (ie still can use the Wrapper object

Re: Getting a dictionary from an object

2005-07-24 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Sun, 24 Jul 2005 02:09:54 +0300, Thanos Tsouanas wrote: (snip) Are you telling me that the ONLY thing you use dictobj objects for is to print them? I don't think so. I do know how to print an object, amazingly. Perhaps you would like to explain how you

  1   2   3   4   5   6   7   8   9   10   >