Re: [Tutor] Extract Block of Data from a 2D Array

2017-03-31 Thread Karim
o to easily reference the element of each column with its column name (given by the header == the first line of the file) Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Working with prime numbers

2015-01-10 Thread Karim
On 08/01/2015 06:25, Steven D'Aprano wrote: Sieve of Eratosthenes Very cool I will use it. Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] xlrd package

2014-04-26 Thread Karim
On 26/04/2014 10:43, Alan Gauld wrote: On 26/04/14 05:48, Sunil Tech wrote: I want to know how many sheets can be created in Excel using xlrd package. This list if for people learning the Python language and standard library. xlrd is not part of that so you may have more success asking

Re: [Tutor] implementing rot 13 problems

2013-03-12 Thread Karim
What can be said after this detailed lesson...Bravo! On 12/03/2013 11:58, Steven D'Aprano wrote: On 12/03/13 16:57, RJ Ewing wrote: I am trying to implement rot 13 and am having troubles. My code is as follows: A few comments follow. def rot_text(self, s): ls = [i for i in s]

Re: [Tutor] How to run multiline shell command within python

2013-01-10 Thread Karim
On 10/01/2013 09:31, Hugo Arts wrote: On Thu, Jan 10, 2013 at 7:01 AM, Karim kliat...@gmail.com mailto:kliat...@gmail.com wrote: Hello all, I want to run multiline shell command within python without using a command file but directly execute several lines of shell. I already

Re: [Tutor] How to run multiline shell command within python

2013-01-10 Thread Karim
On 10/01/2013 16:21, Matty Sarro wrote: Have you looked a the pexpect class? It works like gangbusters, especially if you're trying to run something with an interactive shell. http://www.noah.org/wiki/pexpect On Thu, Jan 10, 2013 at 9:25 AM, Karim kliat...@gmail.com mailto:kliat

[Tutor] How to run multiline shell command within python

2013-01-09 Thread Karim
of code directly. Example: catEOF myfile echo foo echo bar ... EOF Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Problem with mechanize and forms

2012-04-14 Thread Karim Gorjux
me? Thanks -- Karim Gorjux ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] How to have the name of a function inside the code of this function?

2012-04-06 Thread Karim
helpful ;o) If you have any idea to get the caller name inside the caller. Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] How to have the name of a function inside the code of this function?

2012-04-06 Thread Karim
Le 06/04/2012 19:31, Alan Gauld a écrit : On 06/04/12 09:47, Karim wrote: If you have any idea to get the caller name inside the caller. Its not normally very helpful since in Python the same function can have many names: def F(x): return x*x a = F b = F c - lambda y: F(y) print F(1

Re: [Tutor] How to have the name of a function inside the code of this function?

2012-04-06 Thread Karim
Le 07/04/2012 04:01, Dave Angel a écrit : On 04/06/2012 03:19 PM, Karim wrote: Le 06/04/2012 19:31, Alan Gauld a écrit : On 06/04/12 09:47, Karim wrote: If you have any idea to get the caller name inside the caller. Its not normally very helpful since in Python the same function can have

[Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim
package import my_common_utility_fonction. Is it ok to do this? Is it a common practise? Advices are welcome! Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim
Hello All, I have 3 functions, common utilities which I use several times in many modules of a main package. I don't want to create an utilies.py module in the package. Instead I declare it in the __init__.py of the package. Then to use it I do the following: from packe Is it ok to do

Re: [Tutor] Using __ini__.py for common fonctions

2012-02-14 Thread Karim
Le 14/02/2012 20:25, Alan Gauld a écrit : On 14/02/12 19:08, Karim wrote: Advices are welcome! Asking the same question twice does not double your chances of getting a reply. It may even reduce them. As to your question, it's not the most common way to do it, it's not even the way I'd

Re: [Tutor] creating a pie chart in Python

2011-12-07 Thread Karim
/listinfo/tutor With tkinter I made one time a chart so check to be able to do pie one. Another solution is to use pychart cf link below: http://home.gna.org/pychart/ cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] How to raise error without the stack trace

2011-11-27 Thread Karim
trace display. How to modify a Exception type class for that purpose which looks like: classs MyError(Exception): pass Cheers Karim The stack trace is what happens when an exception is uncaught. You don't need to modify it. What you want to do is catch the exception, print

[Tutor] How to raise error without the stack trace

2011-11-26 Thread Karim
Hello, I want to fire my own exception without having the (useful but ugly in my case) stack trace display. How to modify a Exception type class for that purpose which looks like: classs MyError(Exception): pass Cheers Karim ___ Tutor

Re: [Tutor] basic class loading question

2011-11-24 Thread Karim Meiborg
Cranky Frankie wrote: OK, but this is still not working: class Qb: def __init__(self, first_name='', last_name='', phone='', email='', stadium=''): self.first_name = first_name self.last_name = last_name self.phone = phone self.email = email

[Tutor] Template class and class design on concrete example xl2csv writer

2011-11-23 Thread Karim
. Except from that all better design or others critics will be welcome. Regards karim ___ from __future__ import print_function import sys, os, argparse, csv, xlrd

[Tutor] Please code review.

2011-08-02 Thread Karim
Hello, I need a generator to create the cellname in a excell (using pyuno) document to assign value to the correct cell. The following code does this but do you have some optimizations on it, for instance to get the alphabetic chars instead of hard-coding it. Cheers karim Python 2.7.1

Re: [Tutor] Please code review.

2011-08-02 Thread Karim
Thanks Martin, This is the generator expression version. I can use both function generator or generator expression version correction. Cheers Karim On 08/02/2011 02:47 PM, Martin Gracik wrote: def get_cellnames2(rows, cols): rows = range(1, rows + 1) cols = string.ascii_uppercase

Re: [Tutor] Please code review.

2011-08-02 Thread Karim
On 08/02/2011 03:59 PM, Peter Otten wrote: Karim wrote: values = ( (22.5,21.5,121.5), (5615.3,615.3,-615.3), (-2315.7,315.7,415.7) ) it = _xrange_cellnames(rows=len(value), cols=len(values[0])) table.getCellByName(it.next()).setValue(22.5) table.getCellByName(it.next()).setValue(5615.3

Re: [Tutor] Urllib Problem

2011-07-29 Thread Karim
: urllib.request.openurl('www.google.gr/ http://www.google.gr/' + i) But it doesent work.Whats the problem? Please give the exception error you get?! And you should have in the html header the html code error number which gives you the fail answer from the server. Cheers Karim

[Tutor] Is it bad practise to write __all__ like that

2011-07-28 Thread Karim
Hello, __all__ = 'api db input output tcl'.split() or __all__ = api db input output tcl .split() for lazy boy ;o). It is readable as well. What do you think? Cheers Karim

[Tutor] shlex parsing

2011-07-27 Thread Karim
to the shlec properties attributes 'quotes', 'whitespace', etc... But I make 'choux blanc'. If somebody has complex experiences with this module I am in. Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] shlex parsing

2011-07-27 Thread Karim
(at maximum). To bad it is not part of python standard libs. On the other hand, I will have to regroup expression like '-option1 $VAL == $CONSTRAINT' in ['-option1', '$VAL == $CONSTRAINT']. So it seems that I have no others choicse and have to use a parser like pyParsing. Regards Karim On 07/27/2011

[Tutor] Fall in love with bpython

2011-07-27 Thread Karim
, highlights, etc... Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] shlex parsing

2011-07-27 Thread Karim
but using pyParsing still be easer. Thanks Cheers On Wed, Jul 27, 2011 at 2:08 PM, Karim karim.liat...@free.fr mailto:karim.liat...@free.fr wrote: Thank you Dan for answering. I ended with this and gave up with shlex: split = ['-option1', '[get_rule', 'A1', 'B2]', '-option2', '$VAR

Re: [Tutor] Fall in love with bpython

2011-07-27 Thread Karim
On 07/27/2011 12:34 AM, Alan Gauld wrote: Karim wrote: I use bpython interpreter. This is a very good interactive CLI. I had never heard of it and had to google for it. It appears to be a curses based CLI for *nix and MacOS Ah Windows user. I want to create a CLI with the same features

Re: [Tutor] Fall in love with bpython

2011-07-27 Thread Karim
it as well. Cheers Karim Michael * Karimkarim.liat...@free.fr [2011-07-27 23:46]: Hello, I use bpython interpreter. This is a very good interactive CLI. I want to create a CLI with the same features than bpython. But the cmd std module seems no to be used in this project... Is there a tool where I

Re: [Tutor] Fall in love with bpython

2011-07-27 Thread Karim
On 07/28/2011 01:32 AM, Walter Prins wrote: Hi Karim On 28 July 2011 00:04, Karim karim.liat...@free.fr mailto:karim.liat...@free.fr wrote: On 07/27/2011 12:34 AM, Alan Gauld wrote: Karim wrote: I use bpython interpreter. This is a very good interactive

Re: [Tutor] shlex parsing

2011-07-27 Thread Karim
On 07/28/2011 02:27 AM, Steven D'Aprano wrote: Karim wrote: Hello All, I would like to parse this TCL command line with shlex: '-option1 [get_rule A1 B2] -option2 $VAR -option3 TAG' And I want to get the splitted list: ['-option1', '[get_rule A1 B2]', '-option2', '$VAR', '-option3

Re: [Tutor] Strategy to read a redirecting html page

2011-06-01 Thread Karim
On 06/01/2011 01:41 AM, Alexandre Conrad wrote: Hi Karim, When you hit the page and you get an HTTP redirect code back (say, 302), you will need to make another call to the URL specified in the Location parameter in the response headers. Then you retrieve that new page and you can check you got

[Tutor] Strategy to read a redirecting html page

2011-05-31 Thread Karim
you have a better strategy or perhaps some modules deal w/ that issue? I am using python 2.7.1 on Linux ubuntu 11.04 and the modules urllib2, urllib, etc... The webpage is secured but I registered a password manager. cheers karim ___ Tutor maillist

[Tutor] Writing OpenOffice/LibreOffice doc with python

2011-05-19 Thread Karim
Hello All, Is it possible to write document in ODP or DOC format with a python API? Do you know an easy one and popular one which works with python 2.7.1? Cheers Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] Writing OpenOffice/LibreOffice doc with python

2011-05-19 Thread Karim
On 05/19/2011 10:57 PM, Karim wrote: Hello All, Is it possible to write document in ODP or DOC format with a python API? Do you know an easy one and popular one which works with python 2.7.1? Cheers Karim ___ Tutor maillist - Tutor@python.org

[Tutor] What is the trick ???!

2011-05-12 Thread Karim
Hello See below, I was surprised about finding hidden function in module sys: karim@Requiem4Dream: python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. import sys sys.getdefaultencoding() 'ascii

Re: [Tutor] What is the trick ???!

2011-05-12 Thread Karim
On 05/12/11 21:24, Karim wrote: Hello See below, I was surprised about finding hidden function in module sys: karim@Requiem4Dream: python2.7 Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. import sys

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Karim
On 04/11/2011 10:04 AM, tee chwee liong wrote: hi Peter, thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: *-* file:///C:/Python25/myscript/cmm/port1.xml# Test *-* file:///C:/Python25/myscript/cmm/port1.xml# Default_ConfigPort=*8* **

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Karim
On 04/11/2011 07:50 PM, Karim wrote: On 04/11/2011 10:04 AM, tee chwee liong wrote: hi Peter, thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: *-* file:///C:/Python25/myscript/cmm/port1.xml# Test *-* file:///C:/Python25/myscript/cmm/port1

Re: [Tutor] How to use a module when only import package

2011-04-08 Thread Karim
will get answer in 3 seconds. ;o) Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] argparse csv + choices

2011-04-01 Thread Karim
)) return args except ValueError, e: raise argparse.ArgumentTypeError(e) Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] Meta language and code generation

2011-04-01 Thread Karim
will be appreciated! Kind Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

[Tutor] counting a list of elements

2011-04-01 Thread Karim
, indeed, in term of memory I don't want to wast it. But I suppose len() is optimized too (C impementation). If you have some thought to share don't hesitate. Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options

Re: [Tutor] Meta language and code generation

2011-04-01 Thread Karim
On 04/01/2011 08:29 PM, Knacktus wrote: Am 01.04.2011 19:09, schrieb Karim: Hello All, I would to ask you if somebody has experience or can give direction in a new project I have. I have a meta language description (in xml) from which I should generate code on different languages. In my case

Re: [Tutor] counting a list of elements

2011-04-01 Thread Karim
On 04/01/2011 08:41 PM, Knacktus wrote: Am 01.04.2011 19:16, schrieb Karim: Hello, I would like to get advice on the best practice to count elements in a list (built from scractch). The number of elements is in the range 1e3 and 1e6. 1) I could create a generator and set a counter (i +=1

Re: [Tutor] Accessing query results html frame :The solution

2011-02-16 Thread Karim
On 02/16/2011 08:40 AM, Karim wrote: On 02/14/2011 01:41 PM, Karim wrote: Hello, As I get no response from the tutor python list, I am continuing to investigate my problem. In fact the issue is that there are 2 forms in the interactive page and my request does nothing instead I get

Re: [Tutor] Creating xml documents

2011-02-15 Thread Karim
Hello, It seems stefan that version 1.3 still does not validate xml against xsd... Reg On 02/15/2011 02:48 PM, Stefan Behnel wrote: allan oware, 15.02.2011 14:31: Which python modules can one use to create nicely formatted xml documents ? Depends on your exact needs, but

Re: [Tutor] Creating xml documents

2011-02-15 Thread Karim
Hello, It seems stefan that version 1.3 still does not validate xml against xsd... Reg On 02/15/2011 02:48 PM, Stefan Behnel wrote: allan oware, 15.02.2011 14:31: Which python modules can one use to create nicely formatted xml documents ? Depends on your exact needs, but

Re: [Tutor] How to run another python script?

2011-02-14 Thread Karim
possibility: exec( PATH_TO_BBB/BBB ) Or make import of BBB module as below: from BBB import main BBB.main() Regards Karim Please let me know How can I call the BBB file from AAA file. Thanks in advance. Dan ___ Tutor maillist - Tutor@python.org

Re: [Tutor] How to run another python script?

2011-02-14 Thread Karim
Better way is to not have BBB but simply to use Exception (pseudo-code): try: generate zip file ... catch IOError, e: print(Error encountered in generating zip file:, e) else: import os os.remove('path_to_file') Regards Karim On 02/14/2011 05:04 PM, Karim wrote: On 02/14

[Tutor] Accessing query results html frame

2011-02-10 Thread Karim
Hello All, I get from Steven an very useful link (void space) for http authentication. I added some codes to be able to POST FORM a query as I do it by clicking a query button to get a list of bug Id on a server. The problem is I get a html page which refers 2 frames. And I am interesting in

Re: [Tutor] Accessing query results html frame

2011-02-10 Thread Karim
think the request data or whatever) below to access without knowing the temporary html file name generically. Regards Karim On 02/10/2011 07:12 PM, Karim wrote: Hello All, I get from Steven an very useful link (void space) for http authentication. I added some codes to be able to POST FORM

Re: [Tutor] RE module is working ?

2011-02-04 Thread Karim
On 02/04/2011 02:36 AM, Steven D'Aprano wrote: Karim wrote: *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type (appears as stars) but I don't know how to fix it yet. A man when to a doctor and said

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
Hello, Any news on this topic?O:-) Regards Karim On 02/02/2011 08:21 PM, Karim wrote: Hello, I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
\\', expression) (' \\ ', 1) * On linux using my good old sed command, it is working with my '?' (0-1 match): $ echo ' ' | sed 's/\([^\\]\)\?/\1\\/g'* * \\ For me linux/unix sed utility is trusty and is the reference. Regards Karim On 02/03/2011 11:43 AM, Steven D'Aprano wrote: Karim

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
:45 PM, Karim wrote: Hello Steven, I am perhaps a poor tradesman but I have to blame my thunderbird tool :-P . Because expression = *' '* is in fact fact expression = ' '. The bold appear as stars I don't know why. I need to have escapes for passing it to another language (TCL interpreter

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 11:20 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: (snip *Indeed what's the matter with RE module!?* You should really fix the problem with your email program first; Thunderbird issue with bold type

Re: [Tutor] RE module is working ?

2011-02-03 Thread Karim
On 02/03/2011 07:47 PM, Karim wrote: On 02/03/2011 02:15 PM, Peter Otten wrote: Karim wrote: I am trying to subsitute a '' pattern in '\\' namely escape 2 consecutives double quotes: * *In Python interpreter:* $ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3

[Tutor] RE module is working ?

2011-02-02 Thread Karim
= *' '* re.subn(*r'([^\\])?', r'\1\\', expression*) Traceback (most recent call last): File stdin, line 1, in module File /home/karim/build/python/install/lib/python2.7/re.py, line 162, in subn return _compile(pattern, flags).subn(repl, string, count) File /home/karim/build/python/install

Re: [Tutor] Formatting a string

2011-02-01 Thread Karim
Hello, He is {what}.format(what={wild}) 'He is {wild}' Regards Karim On 02/01/2011 09:44 AM, Becky Mcquilling wrote: Quick question to the group to solve an immediate problem and then if anyone has a dead simple reference on formatting strings it would be greatly appreciated as I'm finding

Re: [Tutor] Formatting a string

2011-02-01 Thread Karim
Complete test copy paste: karim@Requiem4Dream:~$ python Python 2.7.1rc1 (r271rc1:86455, Nov 16 2010, 21:53:40) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. He is {what}.format(what={wild}) 'He is {wild}' I don't get the missing . ?! Regards Karim

Re: [Tutor] oops...sorry, just top posted again

2011-01-31 Thread Karim
Is this a SM forum ? Karim On 01/31/2011 04:05 PM, David Hutto wrote: On Mon, Jan 31, 2011 at 8:11 AM, Elwin Estlechrysalis_reb...@yahoo.com wrote: ...but I have an excuse. I had the thing saved in a drafts folder and just hit send without thinking about it. ...I'll just go super glue

Re: [Tutor] Python and Tuples

2011-01-30 Thread Karim
Hello, for x, y in t: print x*y Regards Karim On 01/30/2011 10:29 AM, Becky Mcquilling wrote: I'm fairly new to python and I am trying to do some math with tuples. If I have a tuple: t =( (1000, 2000), (2, 4), (25, 2)) I want to loop through and print out the results of the multiplying

[Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
python code. The web adress is like http://website.com:8081/ddts/ddts_main. If you have link it is welcome! Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
Vince I saw your answer on the related subject fron October 2010 : *Re: [Tutor] Requesting restricted URL (further authentication requested)*. Thanks Karim On 01/28/2011 11:05 PM, Vince Spicer wrote: You may want to look at httplib2 http://code.google.com/p/httplib2/ This great module

Re: [Tutor] Accessing a secured webpage

2011-01-28 Thread Karim
, realm): return self.__user, self.__passwd urlopener = myURLOpener() urlopener.setpasswd(mulder, trustno1)* Basically, we must subclass **urllib.FancyURLopener** and override **prompt_user_passwd(). **Regards Karim ** ** On 01/28/2011 11:15 PM, ian douglas wrote: If it's HTTP

Re: [Tutor] tkinter, create widgets during runtime?

2011-01-27 Thread Karim
)) ... for label in labels: ... label.pack() ... a=gui() a.createLabels() self is the instance of your inherited Frame or else container. Regards Karim On 01/27/2011 01:15 PM, Elwin Estle wrote: From the lack of replies...I am guessing that this can't be done. Tho I just realized I had a typo

Re: [Tutor] tkinter, create widgets during runtime?

2011-01-27 Thread Karim
Hello Wayne, I provided a complete example see the mail above, pretty similar to yours. Regards Karim On 01/27/2011 04:54 PM, Wayne Werner wrote: On Wed, Jan 26, 2011 at 11:21 AM, Elwin Estle chrysalis_reb...@yahoo.com mailto:chrysalis_reb...@yahoo.com wrote: With Tcl/Tk, you can

Re: [Tutor] tkinter, create widgets during runtime?

2011-01-27 Thread Karim
Sorry, I forgot to update continuously the Frame: app.mainloop() Karim On 01/27/2011 02:59 PM, Karim wrote: I never did that but this is python! You can create anything you want at runtime! Make a factory method in you gui class which inherit from Frame or whatever container code below

Re: [Tutor] tkinter, create widgets during runtime?

2011-01-27 Thread Karim
Sorry, I forgot to update continuously the Frame: a.mainloop() Karim On 01/27/2011 02:59 PM, Karim wrote: I never did that but this is python! You can create anything you want at runtime! Make a factory method in you gui class which inherit from Frame or whatever container code below

Re: [Tutor] small ElementTree problem

2011-01-27 Thread Karim
= result.find('name')** * ids.append(idElem.text) names.append(nameElement.text) final = zip(ids, names) * You are not obliged to provide the full XPATH. Etree search for you. Regards Karim On 01/27/2011 11:23 PM, Alex Hall wrote: Hi all, I am using, and very much enjoying, the ElementTree library

Re: [Tutor] class question

2011-01-26 Thread Karim
the same style. Regards Karim On 01/26/2011 12:08 PM, Alan Gauld wrote: Karim karim.liat...@free.fr wrote Program towards interface that means you have to use inheritance. Just to be picky, you can program by interface without using inheritance. Inheritance is only needed to implement

Re: [Tutor] class question

2011-01-26 Thread Karim
I know the the law of Murphy. But this one is a must-have.:-) Regards Karim * One way to reduce coupling is with the Law of Demeter: if you want your dog to walk, don't talk to your dog's legs. You will only confuse the dog and it won't get anywhere. http://en.wikipedia.org/wiki

[Tutor] Print to std output with color

2011-01-26 Thread Karim
of _/decorate_output( mode=WARNING, *'This is a warning!')*/_ Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Print to std output with color

2011-01-26 Thread Karim
Thanks a lot Scott for the tip! Regards Karim On 01/26/2011 07:10 PM, Scott Nelson wrote: Curses is one way to go. Another is to use the PyWin32 module discussed in this thread: http://thread.gmane.org/gmane.comp.python.tutor/58450/focus=58454 Basically, here's a snippet of code that can

Re: [Tutor] Print to std output with color

2011-01-26 Thread Karim
Thanks Alan! I will go there have a look. Regards Karim On 01/26/2011 07:24 PM, Alan Gauld wrote: Karim karim.liat...@free.fr wrote Is there a simple way to print with color to stdout like the unix/linux example below: *print( '^[[1;31mThis is a warning!^[[0m' ) Not generically since

Re: [Tutor] Print to std output with color

2011-01-26 Thread Karim
That's what I figured out at effbot website. Thanks for the additional link Alan! Regards Karim On 01/26/2011 07:27 PM, Alan Gauld wrote: Karim karim.liat...@free.fr wrote Is there a simple way to print with color to stdout like the unix/linux example below: *print( '^[[1;31mThis

[Tutor] The trap of the year

2011-01-25 Thread Karim
= [] ... def param(self): ... print(id(self.parameters)) ... a=Device() b=Device() b.param() 140559202956496 a.param() 140559202956568 Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
surprise! I never see warning about this fact in any books before. Regards Karim On 01/25/2011 10:08 PM, Izz ad-Din Ruhulessin wrote: Or the internal memory id or whatever it's called. 2011/1/25 Izz ad-Din Ruhulessin izzaddin.ruhules...@gmail.com mailto:izzaddin.ruhules...@gmail.com I think

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
time a new argument init. Regards Karim On 01/25/2011 10:20 PM, bob gailer wrote: *values are evaluated when th* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
On 01/25/2011 10:12 PM, Jerry Hill wrote: On Tue, Jan 25, 2011 at 3:41 PM, Karim karim.liat...@free.fr mailto:karim.liat...@free.fr wrote: I am not really understanding why my init in the class made it refers to the same list object. What is the difference with 2nd example directly

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Yes you're right. But the class and instance thing made me believe the context would be different. Error of judgment. Regards Karim On 01/25/2011 10:57 PM, Corey Richardson wrote: On 01/25/2011 04:28 PM, Karim wrote: Hello Bob, I know this fact for function but in this case

Re: [Tutor] placing widgets

2011-01-25 Thread Karim
several Frames and place your widget in it if you want more specific placements. Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Thanks for the tip Steven. Regards Karim On 01/26/2011 12:39 AM, Steven D'Aprano wrote: Karim wrote: Hello Bob, I know this fact for function but in this case this is not a function but a constructor method of a class. Methods *are* functions. (Technically, they are lightweight wrappers

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
After one 2 months of python intensive development. I made this init defaults error in my db classes constructors... Shame on me :-[ Steven ! Your example shows me obvious. Regards Karim On 01/26/2011 12:33 AM, Steven D'Aprano wrote: Karim wrote: Hello All, Just to share on rageous bug

Re: [Tutor] The trap of the year

2011-01-25 Thread Karim
Sorry Alan, When I read your tutorial I was probably blind... :-D I am going to re-read it. Regards Karim On 01/26/2011 01:30 AM, Alan Gauld wrote: Karim karim.liat...@free.fr wrote If I understand a little bit what happen in: def __init__(self, parameters=[]): [...] The list

Re: [Tutor] class question

2011-01-25 Thread Karim
. Try to determine the objects you need for your problem and next step is how arrange it together (relational). Regards Karim On 01/26/2011 01:28 AM, Marc Tompkins wrote: On Tue, Jan 25, 2011 at 3:26 PM, Elwin Estlechrysalis_reb...@yahoo.com wrote: Is it better to have one large sort of do

Re: [Tutor] Help listing directory timestamps and deleting directories

2011-01-24 Thread Karim
Hello, Also working w/o external module just the standard one: * import datetime remove_after = datetime.datetime.now() - datetime.timedelta(days=31) remove_after datetime.datetime(2010, 12, 24, 23, 21, 10, 11315) * Regards Karim On 01/24/2011 08:02 PM, Vince Spicer wrote: On Mon, Jan 24

Re: [Tutor] Why super does not work !

2011-01-18 Thread Karim
): a = self.sujet.getValue() self.text.set(data_base[a][0])* I still need a advice about the possible improvement specially for Entry observer object. Regards Karim On 01/18/2011 07:31 AM, Karim wrote: Thanks Izz, Luke, Steven and Alan! That's I figured out with MI and super. Steven I understand

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
Hello Steven, (1) slots = [] doesn't do anything special. You have misspelled __slots__. Yes sorry my mistake :-[ (2) Classes don't become read only just because you add __slots__ to them. All you prevent is adding extra attributes, and why would you wish to do that? I know this is ugly

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
. Thanks! Regards Karim On 01/18/2011 02:24 PM, bob gailer wrote: On 1/18/2011 8:08 AM, Karim wrote: I know this is ugly but until now it is the only way (with this side effect) I found to declare Enums class that I _understand_: *class CategoryType(object): Implements the enumeration

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
On 01/18/2011 03:38 PM, bob gailer wrote: def __getattr__(self, name): return self.enums[name] Note this does not handle the upper/lower case issue. Thanks for the trick! works perfect! Regards Karim ___ Tutor maillist - Tutor

Re: [Tutor] Why super does not work !

2011-01-18 Thread Karim
On 01/17/2011 11:36 PM, Dave Angel wrote: On 01/-10/-28163 02:59 PM, Karim wrote: Hello, I implemented Observer DP on a listbox (Tkinter) as follows and I don't understand why super() is not working and Observable.__init__(self) is working, cf below: class ListObservable(Listbox, Observable

Re: [Tutor] What is __weakref__ ?

2011-01-18 Thread Karim
Thanks for the links Steven! Regards Karim On 01/18/2011 10:49 PM, Steven D'Aprano wrote: Karim wrote: Same thing I don't know what to do with this object weakref :-[ as I don't know its meaning. That was my true question in fact; http://mindtrove.info/python-weak-references/ http

[Tutor] What is __weakref__ ?

2011-01-17 Thread Karim
Hello, I am wondering what is this special class attribut. I know __dict__, slots. I use slots = [] when I want to use a read only class. But is anyone could explain with a little example the use of __weakref__? Regards karim ___ Tutor maillist

[Tutor] Why super does not work !

2011-01-17 Thread Karim
/home/karim/guiObserver/observable.py, line 11, in attach self._observers.append(observer) AttributeError: 'ListObservable' object has no attribute '_observers' And the Observable class is: class Observable(object): Sujet a observer def __init__(self): self._observers

Re: [Tutor] Why super does not work !

2011-01-17 Thread Karim
). The code is working but I am not totally happy because of many EntryObserver almost identical objects (except from update and grid() options) Is it possible to simplify this structure? Regards Karim The rest of the code is below: #!/usr/bin/env python2.7 Module ObserverGraphique.py Une

Re: [Tutor] end parameter in 2.7.1?

2011-01-15 Thread Karim
IN 3.1 for print(): print('hello', end =' ') hello It suppress the newline character. On 01/15/2011 07:05 PM, Emile van Sebille wrote: On 1/15/2011 9:35 AM Bill DeBroglie said... Twice in two days...! Using Mac OS X 10.5.8 and Python 2.7.1 but am following a book which is using Python

  1   2   >