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

2011-02-14 Thread Karim
end. One possibility: exec( "/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 -

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: ... catch IOError, e: print("Error encountered in generating zip file:", e) else: import os os.remove('') Regards Karim On 02/14/2011 05:04 PM, Karim wrote: On 02/14/2011 04:

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 xml.etree.ElementT

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 xml.etree.ElementT

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 the

Re: [Tutor] argparse csv + choices

2011-04-01 Thread Karim
gs = csv.split(',') remainder = sorted(set(args) - set(self.choices)) if remainder: raise ValueError("invalid choices: %r (choose from %r)" % (remainder, self.choices)) 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
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
list, 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 subsc

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] Meta language and code generation

2011-04-01 Thread Karim
On 04/02/2011 06:38 AM, Knacktus wrote: Am 01.04.2011 20:56, schrieb 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

Re: [Tutor] counting a list of elements

2011-04-01 Thread Karim
On 04/02/2011 07:00 AM, Knacktus wrote: Am 01.04.2011 21:31, schrieb 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

Re: [Tutor] Finding prime numbers script runs much faster when run via bash shell than idle

2011-04-01 Thread Karim
nter += 1 And IDLE add a layer due to the interactive feature to display result. It is python interpreter plus Tk layer. Just a thought nothing truly precise. Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subsc

Re: [Tutor] Finding prime numbers script runs much faster when run via bash shell than idle

2011-04-01 Thread Karim
ter += 1 And IDLE adds a layer due to the interactive feature to display result. It is python interpreter plus Tk layer. Just a thought nothing truly precise. Regards Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subsc

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

2011-04-08 Thread Karim
n/listinfo/tutor Hello, Test it simply! You 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] 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: *-* *-* ** *2* ** *3* ** ** it overwrites every time the port number is incremented and only capture the last iteration numb

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: *-* *-* ** *2* ** *3* ** ** it overwrites every time the port number is incremented

[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&qu

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

[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 To

[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

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

[Tutor] shlex parsing

2011-07-27 Thread Karim
TAG'] Then I will gather in tuple 2 by 2 the arguments. I tried 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 _

Re: [Tutor] shlex parsing

2011-07-27 Thread Karim
, '$VAR', '-option3', 'TAG'] ['-option1', '[get_rule A1 B2]', '-option2', '$VAR', '-option3', 'TAG'] Sure pyParsing seems to be pretty simple but my constraint is to use standard lib (at maximum). To bad it is

[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
using pyParsing still be easer. Thanks Cheers On Wed, Jul 27, 2011 at 2:08 PM, Karim <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', &

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 * Karim [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 can plug a

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 <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 CLI.

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]&#x

[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 a

Re: [Tutor] Urllib Problem

2011-07-29 Thread Karim
adlines() for i in x: 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 a

[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

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

2011-11-23 Thread Karim
tern which usually goes with the Template pattern. Except from that all better design or others critics will be welcome. Regards karim ___ from __future__ import p

[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] How to raise error without the stack trace

2011-11-27 Thread Karim
Le 26/11/2011 15:20, Rich Lovely a écrit : On 26 November 2011 11:41, Steven D'Aprano wrote: Hugo Arts wrote: On Sat, Nov 26, 2011 at 11:16 AM, Karim wrote: Hello, I want to fire my own exception without having the (useful but ugly in my case) stack trace display. How to mod

Re: [Tutor] creating a pie chart in Python

2011-12-07 Thread Karim
n.org To unsubscribe or change subscription options: http://mail.python.org/mailman/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] Using __ini__.py for common fonctions

2012-02-14 Thread Karim
from 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 thi

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 t

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

2012-04-06 Thread Karim
me. This is not more 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] How to run multiline shell command within python

2013-01-09 Thread Karim
l lines of code directly. Example: cat< 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

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 <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 al

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 <mailto:kliat...@gmail.com>> w

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] 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 on

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] Extract Block of Data from a 2D Array

2017-03-31 Thread Karim
all columns. The csv module allows you to 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

[Tutor] Removing redundant parameters in a models file having include files.

2010-02-26 Thread karim . liateni
final file with filtered include. I am using python 2.2 so I have not use latest feature I want my code to run on old Solaris too (linux user). I use as much as possible list comprehension following your advices. I don't like the part: if matchParam: return True else:

[Tutor] Fwd: Removing redundant parameters in a models file having include files.

2010-02-26 Thread karim . liateni
final file with filtered include. I am using python 2.2 so I have not use latest feature I want my code to run on old Solaris too (linux user). I use as much as possible list comprehension following your advices. I don't like the part: if matchParam: return True else:

Re: [Tutor] Removing redundant parameters in a models file having include files.

2010-02-27 Thread Karim Liateni
Ok I must add an explanation The program must removes includes files of already existing parameters in the models file. Karim karim.liat...@free.fr wrote: Hello All, This is my first program in python. I am doing electrical simulation in spectre (spice like). I have a models file which

[Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni
my code to run on old Solaris too (linux user). I use as much as possible list comprehension following your advices. I don't like the part: if matchParam: return True else: return False Is there an easy way to do the same behavior. I am not sure but I saw one time something like

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni
Hello Alan, Alan Gauld wrote: "Karim Liateni" wrote It concatenates both parameters and include files with the same parameters definitions. That trigs errors during simulation and it complains about parameters double definition. I'd suggest you construct a dictionary bas

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni
as (fin, fout): fout.write(fin.read()) or even better, as Alan suggested, using shutil.copyfile(). ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor Thank you Lie but I have a restriction on the python vers

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Karim Liateni
Lie Ryan wrote: On 03/01/10 02:49, Karim Liateni wrote: Lie Ryan wrote: On 03/01/10 01:12, Alan Gauld wrote: def getLines(file): """Get the content of a file in a lines list form.""" f = open(file, 'r') lines =

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-01 Thread Karim Liateni
sp it was war fields. It's better to spent energy to participate with the core developers to make the common langage evoluate. Regards Karim Alan Gauld wrote: "Karim Liateni" wrote def getLines(file): try: lines = open(filename).readlines() ; return lines except IOError: #h

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-02 Thread Karim Liateni
Hello, Thanks a lot for this state of the art of the language, very instructive. I see now top of the iceberg ;o) Karim Steven D'Aprano wrote: On Tue, 2 Mar 2010 07:07:57 am Karim Liateni wrote: Thanks for this precision! I'm using standard python so this is ok! Why

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-03-03 Thread Karim Liateni
Hello Alan, Steven, I was narrow minded about this topic and did not see the benefits of these multiple Python implementations. You opened my eyes. Regards Karim Steven D'Aprano wrote: On Tue, 2 Mar 2010 11:25:44 am Andreas Kostyrka wrote: Furthermore I do not think that most o

Re: [Tutor] parsing a "chunked" text file

2010-03-03 Thread Karim Liateni
strip()] I tried to write as well the second function but it is not as straight forward. I begin to understand the use of yield in it. Regards Karim Steven D'Aprano wrote: On Tue, 2 Mar 2010 05:22:43 pm Andrew Fithian wrote: Hi tutor, I have a large text file that has chunks of data l

Re: [Tutor] parsing a "chunked" text file

2010-03-19 Thread Karim Liateni
Hello, Thanks both of you for these useful information. Regards Karim Hugo Arts wrote: On Thu, Mar 18, 2010 at 12:54 PM, Stefan Behnel wrote: Karim Liateni, 04.03.2010 01:23: Yes, a *big* difference in the true sense of the word. Your code (assuming you meant to write "... for li

[Tutor] Tutorial executable from python script.

2010-03-19 Thread Karim Liateni
f you have any links I would love to have it Thanks Karim ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Tutorial executable from python script.

2010-03-20 Thread Karim Liateni
depand on any local machine installation environment. I need as to embed gtk python library for graphical use. Thanks Karim Alan Gauld wrote: "Karim Liateni" wrote on machine which doesn't have recent version (2.0) of python. Given that v2 is at least 10 years old now th

Re: [Tutor] Tutorial executable from python script.

2010-03-21 Thread Karim Liateni
x27;t want to rely on machine installation and provide a unique version with my application installation. I know we did the same for TCL to be sure to have 8.4 version. I just wanted to know if there is some tutos about this topic. Regards Karim Lie Ryan wrote: On 03/21/2010 06:00 AM, Karim Lia

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] Problem with mechanize and forms

2012-04-14 Thread Karim Gorjux
ny of these forms! I need the first form so I tried br.select_form(nr=0) but I get None! Any number I tried get None as result for i in range(6): print br.select_form(nr=i) None None None None None None Anyone can help me? Thanks -- Karim Gorjux __

<    1   2