Re: [Tutor] newbie to gui programming

2010-07-08 Thread Noufal Ibrahim
Payal payal-pyt...@scriptkitchen.com writes: [...] Thanks a lot for the mails all of you. Someone commented that wxpython occassionally shows it C/C++ roots. Will that haunt me cos' I have zero knowledge of C/C++. What about py-gtk? Is it more pythonic to learn and hence easy? I've used wx

[Tutor] Passing nested structures to fcntl.ioctl

2010-03-07 Thread Noufal Ibrahim
Hello everyone, I have some code that's calling fcntl.ioctl. I need to pass a nested structure as the 3rd argument of the function. Something like this typedef struct coordinates{ int x; int y; } coordinates; typedef struct point{ int amp; coordinates* coord; } point; How would I

Re: [Tutor] Stack unwind using exceptions.

2009-07-05 Thread Noufal Ibrahim
Kent Johnson wrote: [..] Why not just return the value from the function and pass it up the call chain? If a call fails return None. Something like this: That's what I ended up doing but the first thing occurred to me and I was just wondering if there's any production code that relies on the

Re: [Tutor] Poor style to use list as array?

2009-07-05 Thread Noufal Ibrahim
Angus Rodgers wrote: [..] This feels like a bit of a cheat, as if I am trying to program in Python as if it were some other more familiar language. Should I have coded this differently? I can't offer anything concrete but here are some things that occur to me at a glance. 0. You can try

[Tutor] Stack unwind using exceptions.

2009-07-04 Thread Noufal Ibrahim
Hello everyone, Would it be considered unorthodox or 'wrong' in some sense for me to use an exception to unwind the stack and return to a caller for a recursive function? I need to do a depth first search and when I find the right element to just stop the whole thing, and get back to the

Re: [Tutor] Python popen command using cat textfile .... how to terminate

2009-05-15 Thread Noufal Ibrahim
MK wrote: Hi there, i am using this code to send an cat ThisIsMyUrl with popen. Of cos cat now waits for the CTRL+D command. How can i send this command ? Wouldn't it be better if you directly opened the ThisIsMyUrl file and wrote the text into it rather than rely on shelling out for this?

Re: [Tutor] How many types of the constructor

2009-04-27 Thread Noufal Ibrahim
Greetings Sudanshu, sudhanshu gautam wrote: when we work on the oops in the python then we have to pass the first parameter as a self then the value of the other parameters . Well, not explicitly. If you're familiar with OOPS in C++, self is analogous to the this pointer there. Also, you

Re: [Tutor] Automated function creation / outsourcing code

2009-03-31 Thread Noufal Ibrahim
Oxymoron wrote: I think you're looking for refactoring features, in this particular case, a compose method/function refactor. Generally, generic editors will have trouble doing this right since it requires some inferencing capability on the selected code, your best bet is probably googling

Re: [Tutor] reading lists from a text file

2009-03-12 Thread Noufal Ibrahim
Emad Nawfal (عماد نوفل) wrote: Hi Tutors, I've never had a situation in which this was useful for me, but I'm just curious. If there is a text file that has a list or number of lists in it, is there is a way to read the lists in the file as lists, and not as a string. Sample file attached.

Re: [Tutor] overwriting input file

2009-02-25 Thread Noufal Ibrahim
Bala subramanian wrote: Hello all, query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. import fileinput pat1= R pat2=U5 pat3=A3

Re: [Tutor] overwriting input file

2009-02-25 Thread Noufal Ibrahim
A.T.Hofkamp wrote: write the output to a temporary file while reading the input, then rename the temporary file. This I believe is what the fileinput module does when you use it with the inplace parameter set to 1. -- ~noufal http://nibrahim.net.in/

Re: [Tutor] Python 2.6.1 + Linux Ubuntu (Gutsy Gibbon)

2009-02-07 Thread Noufal Ibrahim
Eric Dorsey wrote: I am trying to teach myself Linux, and so I'm running Ubuntu (Gutsy Gibbon) as a virtual machine. I went to terminal, started up Python and realized it was version 2.5 so I thought I'd just upgrade to 2.6.1 After doing some Googling around, it seems that Ubuntu is highly

Re: [Tutor] Selecting first matching element from a list

2009-01-14 Thread Noufal Ibrahim
bob gailer wrote: 2) looks bad and is ugly are emotional responses. What are you feeling and wanting when you say those things? It's hard for me to qualify really but my general idea of list comprehensions is that they transform and filter lists creating other lists. For instance, I'd

[Tutor] Selecting first matching element from a list

2009-01-12 Thread Noufal Ibrahim
Hello everyone, What is the pythonic was of selecting the first element of a list matching some condition? I often end up using [x for x in lst if cond(x)][0] This looks bad and raises IndexError if nothing is found which is ugly too. Thanks. -- ~noufal

Re: [Tutor] Running Two Versions of Python on the Same PC

2008-10-11 Thread Noufal Ibrahim
Wayne Watson wrote: Is it possible to do as in Subject on Win XP? Say, 2.4 and 2.5. -- You can create virtual installations of Python which might work for you. I do it for custom package installation etc. The virtualenv pakcage is what I use. http://pypi.python.org/pypi/virtualenv --

Re: [Tutor] Simple physics simulations)

2008-09-14 Thread Noufal Ibrahim
Jim Morcombe wrote: I want to write a program that helps teach students how to draw ray diagrams for lenses and mirrors. Vpython seems to be used for a number of physics simulations, but may be overkill for my application. Although there are a few 3D things I would like to do, most just

Re: [Tutor] (no subject)

2008-07-29 Thread Noufal Ibrahim
Morgan Thorpe wrote: Hello. I'm am very new to the whole programming sence. Welcome. :) I am trying to catch on but as soon as i want to write a program i've been told to use like 'notepad' in windows XP and save it as a .py file i have gotten this far. Am i wrong so far? It's fine so

Re: [Tutor] (no subject)

2008-07-20 Thread Noufal Ibrahim
amit sethi wrote: Hi list , Can someone give me an idea about the audio libraries in python . I tried using pymedia . What are the options available . These may be a little heavy duty for you but they do audio. 0. Pyglet (Full windowing and multimedia library) - http://pyglet.org/ 1.

Re: [Tutor] Web Stats

2008-06-15 Thread Noufal Ibrahim
Kent Johnson wrote: On Wed, Jun 11, 2008 at 3:58 PM, Stephen Nelson-Smith [EMAIL PROTECTED] wrote: Hello, This has to include resources which have not been visited, as the point is to clean out old stuff. wouldn't a 'find' for files with a an ancient access time be a better way of finding

Re: [Tutor] Programming Ideas, need some focus

2008-01-16 Thread Noufal Ibrahim
Fiyawerx wrote: I've been over google for hours now, and I'm sort of at a lull in my learning, as I don't really have a current goal. I know I could set some easy goal like to learn a specific function or feature, but I still have a hard time with that approach also. I was wondering if

[Tutor] Formatting timedelta objects

2007-12-10 Thread Noufal Ibrahim
Hello everyone, This is probably something simple but I can't seem to find a way to format a timedelta object for printing? I need to be able to print it in a HH:MM:SS format but without the microseconds part (which is what you get if you str() it). Any pointers? Thanks. -- ~noufal

Re: [Tutor] Logging in Linux

2007-10-24 Thread Noufal Ibrahim
wormwood_3 wrote: Now, what I would like to do is instead send this output to one or more of the standard linux log files. First though, I am wondering, what is the standard procedure in a case like this? You can either have a config file to specify a log area or use syslog to do the

Re: [Tutor] Timers in Python

2007-10-04 Thread Noufal Ibrahim
Kent Johnson wrote: Kamal wrote: hello everyone, Is there a method in Python which does what setInterval('someFunction()',5000) does in Javascript. Basically, I want to call functionOne() every x minutes, and wondering whats the best way to do it. You can also look at the sched module

Re: [Tutor] A simple Question...

2007-10-02 Thread Noufal Ibrahim
bhaaluu wrote: On 10/2/07, Kent Johnson [EMAIL PROTECTED] wrote: traceback.print_stack() prints the stack trace to the current point of execution. No forced error or drama needed :-) Kent Exactly how is this used, please? Traceback (most recent call last): File print_stack.py, line

Re: [Tutor] using **kwargs in __init__() as attributes

2007-10-01 Thread Noufal Ibrahim
János Juhász wrote: Dear Tutors, I would like to make a new class instance, where the intance attributes coming from the kwargs hash. class ADUser: def __init__(self, **kwargs): for key in kwargs.keys(): self.key = kwargs[k] a = ADUser(name='papa') Your

Re: [Tutor] linux terminal coloring in python

2007-09-30 Thread Noufal Ibrahim
Robert Jackson wrote: I'm trying to get some pretty colored output for a Linux console / terminal window. Google searches only reveal the curses module to colorize output. Is there a simpler way? Curses seems to be FAR too powerful for what it is I want to do (simply to colorize a few

Re: [Tutor] questions about tuples

2007-09-30 Thread Noufal Ibrahim
Fangwen Lu wrote: Dear all- I want to do some loops. Each loop will generate a tuple. Eventually I want to put tuples together in a higher level of tuple. Do you know how to do this? Say a=(1,2,3), b=(4,3,2),c=(9,5,6). I want to get a tuple as ((1,2,3), (4,3,2),(9,5,6)). If

Re: [Tutor] CGI File Woes

2007-09-30 Thread Noufal Ibrahim
wormwood_3 wrote: Hello all, I am working on a very simple CGI script. The site I want to use it on is a shared linux host, but I confirmed that .py files in the right dir with the right permissions and shebang execute just fine, Hello World sort of tests were successful. Those are the first

Re: [Tutor] how to convert array into tuple

2007-09-28 Thread Noufal Ibrahim
bhaaluu wrote: Can you explain how this works? How would this be written in a conventional way? I'm not sure if this is addressed to me but I'll reply anyway. :) foo = [1,2,3,4,5,6] [(foo[i],foo[i+1]) for i in range(0,len(foo),2)] range(0,len(foo)) would create a list of consecutive numbers

Re: [Tutor] how to convert array into tuple

2007-09-27 Thread Noufal Ibrahim
Fangwen Lu wrote: Dear all- If I have an array array([1, 2, 3, 4, 5, 6]), and I want to get ((1,2),(3,4),(5,6)). What should I do? This seems to work although I'd like comments from the more experienced Pythonistas out there. foo [1, 2, 3, 4, 5, 6, 7, 8, 9] [(foo[i],foo[i+1]) for i

Re: [Tutor] largest and smallest numbers (Linpeiheng)

2007-09-25 Thread Noufal Ibrahim
林培恒 wrote: On Mon, 24 Sep 2007, Terry Carroll write: My math is rusty. Is there a concept of greater than or largest in complex numbers on different axis? Which is larger, 4+2i or 2+4i? In fact, complex numbers can not compare directly. People always compare complex numbers with their

Re: [Tutor] data type conversion for print statement

2007-09-25 Thread Noufal Ibrahim
Tim wrote: Hello, I have a print statement where I use concatenation of variables with + to avoid extra whitespaces. The variables are mixed (float/int). How can I convert them all to strings to have a clean print statement? example print str(var1)+and this +str(var2)+needs to check

Re: [Tutor] pythons xf86misc documentation ?

2007-09-24 Thread Noufal Ibrahim
dave selby wrote: Can anyone tell me where the documentation for pythons xf86misc module is, ie what methods are avalible ? I've not used this module you mention myself but if it's got docstrings and inline documentation, you can get help by importing the module and then doing a

[Tutor] Decorators and function arguments.

2007-09-19 Thread Noufal Ibrahim
Hello everyone, I have a question regarding the use of some decorators. In my program, I have functions like this def process_command_line(...): ... def run_command(...): ... def update_db(...): ... These functions are for various stages of the program. Now, I need to

Re: [Tutor] Decorators and function arguments.

2007-09-19 Thread Noufal Ibrahim
Kent Johnson wrote: Noufal Ibrahim wrote: My question is whether this is a valid use for a decorator and whether this kind of usage is pythonic. If not, are there any better ways to do this? It seems like a bit of a hack to me. I guess you change the way you call run_command to include

Re: [Tutor] Running other files

2007-09-11 Thread Noufal Ibrahim
Rikard Bosnjakovic wrote: On 10/09/2007, Lawrence Barrott [EMAIL PROTECTED] wrote: is it possible to run other non-python files using python such as .exe or other files. Have a look at os.system(). Or more generally, the subprocess module. -- ~noufal

Re: [Tutor] advanced sorting

2007-09-04 Thread Noufal Ibrahim
chinni wrote: In Advance Sorting by giving the keywords to sort the list.But, iam getting the fallowing errors x = ['srikanth', 'kumar', 'muppandam', 'will', 'be', 'a'] x.sort(key=len) Traceback (most recent call last): File stdin, line 1, in ? TypeError: sort() takes no

Re: [Tutor] client server apps

2007-08-26 Thread Noufal Ibrahim
[EMAIL PROTECTED] wrote: Hi! What's the point in having a server app between the user frontend and a database backend? (As is the case of TinyERP wich is writen in python-GTK) Can't simillar functionality be achieved without that server? What are the main pro's and con's? Off

Re: [Tutor] Question about classes

2007-08-25 Thread Noufal Ibrahim
Ara Kooser wrote: Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. When I run the program I and type no when prompted I get the following message: Traceback (most recent call

Re: [Tutor] iterate list items as lvalue

2007-08-20 Thread Noufal Ibrahim
János Juhász wrote: Dear Tutors! I know a python list is a mutable object. array = [1,2,3,4,5] So I can modify any item in it. for index in range(len(array)): array[index] *= 2 ... array [2, 4, 6, 8, 10] So I typed this: for item in array: item *= 2 ... array [1, 2, 3, 4, 5]

Re: [Tutor] Class Attribute Overloading?

2007-08-15 Thread Noufal Ibrahim
Vincent Gulinao wrote: Sorry, I just started experimenting on Python classes... Is there any way a reference to a class attribute ([class].[attribute]) be treated like a method ([class].[method]())? I have a class with DB component. Some of its attributes are derived from DB and I

Re: [Tutor] Losing theexpressivenessofC'sfor-statement?/RESENDwithexample

2007-08-11 Thread Noufal Ibrahim
Stephen McInerney wrote: Hi Alan, [..] How can we address that reasonably and succinctly without polluting the doc with language-migration-specific details, that is a worthy question... I believe we can do a better job simply by grouping and highlighting related alternative concepts like I

[Tutor] subprocess and signals

2007-08-07 Thread Noufal Ibrahim
Hello everyone, I've come across a situation which is somewhat confusing to me. I googled for some details and came across another email thread on this very list but couldn't really glean a solution out of it. I have a program (a compiled binary) for which I need to write a wrapper (in

Re: [Tutor] subprocess and signals

2007-08-07 Thread Noufal Ibrahim
Eric Brunson wrote: Noufal Ibrahim wrote: [..] def createSignalDelegator(p): def sighandler(signal,frame,pmake = p): os.kill(pmake.pid,signal) return sighandler pmake = subprocess.Popen(pmake_cmd, bufsize = 1, stdout = subprocess.PIPE, stderr = subprocess.STDOUT

Re: [Tutor] correlation matrix

2007-07-21 Thread Noufal Ibrahim
Beanan O Loughlin wrote: hi all, I am new to python, and indeed to programming, but i have a question regarding correlation matrices. If i have a column vector x=[1;2;3;4;5] and its transpose row vector xt=[1,2,3,4,5] is there a simple way in python to create a 5x5 correlation

Re: [Tutor] Module imports

2007-07-11 Thread Noufal Ibrahim
kevin parks wrote: With sincere apologies for such a basic question, and one i will admit that i asked once before, moons ago. But even after googling around a bit i don't understand what the right answer is, or if i once did, can't recall it now.. [..] For some reason i feel like i

[Tutor] Python maintenance taks

2007-06-25 Thread Noufal Ibrahim
Hello everyone, I seem to recall that there was a site (on the python wiki IIRC) that listed relatively simple python bugs (in the actual C code inside the interpreter) that needed to be fixed. It was advertised as good starting point for novices. I can't seem to find it. Does anyone

[Tutor] TCLtutor like python program

2007-04-08 Thread Noufal Ibrahim
Hello everyone, A couple of months ago, I had posted on this list asking about the usefulness of such a program. Something similar to TclTutor (http://www.msen.com/~clif/TclTutor.html) for python. I've spent some time on this and have come up with a crude first version. I'd appreciate if

Re: [Tutor] python web dev

2007-01-04 Thread Noufal Ibrahim
OkaMthembo wrote: hi pythonistas! this is my first post. please could you tell me which is the best lightweight python web framework? also, which is the best templating language for python? (which can handle other data formats in addition to text). so far im lured by Cheetah, although i

Re: [Tutor] (no subject)

2006-11-28 Thread Noufal Ibrahim
Kopalle Narasimha wrote: Hello, Everyone. I have a strange problem with floating point numbers. Please help me. I tried the following at the python prompt: Case 1: 4.5/2.0 #Gives quotient Answer: 2.25 Case 2: 4.5%2.0 #Gives Remainder Answer: 0.5 I don't think it's

Re: [Tutor] how to extract time from datetime.date.time()

2006-11-16 Thread Noufal Ibrahim
Asrarahmed Kadri wrote: Hi, I want to extract hh:mm:ss from below mentioned code: import datetime t = datetime.datetime.now() print t 2006-11-16 16:59:02.843000 How to do it? Did you read the documentation and try something out before posting this question on the list? --

Re: [Tutor] Not able to store result between function call.. Help needed

2006-11-13 Thread Noufal Ibrahim
Asrarahmed Kadri wrote: Hi Folks, I have a textbox and a button (in tkinter). What I want is the following functionality: The user enters a number in the text box and presses the button. The event will call a function called adder and when the user enters another value and

Re: [Tutor] Wrong module name and line number in logging package.

2006-11-06 Thread Noufal Ibrahim
Noufal Ibrahim noufal at airtelbroadband.in writes: Greetings everyone, I'm using the python standard logging package for a personal project of mine and have initialised it like so. logger = logging.getLogger(pydagogue) handler = logging.StreamHandler() handler.setFormatter

[Tutor] Wrong module name and line number in logging package.

2006-11-05 Thread Noufal Ibrahim
Greetings everyone, I'm using the python standard logging package for a personal project of mine and have initialised it like so. logger = logging.getLogger(pydagogue) handler = logging.StreamHandler() handler.setFormatter(logging.Formatter([%(levelname)s]%(pathname)s:%(lineno)d %(message)s))

[Tutor] Isolation of code

2006-10-08 Thread Noufal Ibrahim
Greetings everyone, I'm working on a little project that's similar to tcltutor for python. I have a string which has some python code. I compile and eval this to get the output. So far so good. However, when this happens, the evaluation is happening in the current namespace so I'm afraid of

[Tutor] Isolation of code

2006-10-08 Thread Noufal Ibrahim
Greetings everyone, I'm working on a little project that's similar to tcltutor for python. I have a string which has some python code. I compile and eval this to get the output. So far so good. However, when this happens, the evaluation is happening in the current namespace so I'm afraid of

Re: [Tutor] Tkinter and python

2006-10-08 Thread Noufal Ibrahim
max . wrote: first off i just started looking for Tkinter tutorials but havent found much and what i have found was not very good if anyone knows og any Tkinter tutorials pleas let me know Try this for a good tutorial http://www.pythonware.com/library/tkinter/introduction/ Peace.

[Tutor] Debugging multithreaded programs in python

2006-08-01 Thread Noufal Ibrahim
Greetings all, A friend here is trying to debug a rather badly written python program which spawns off lots of threads here and there. Are there any frameworks that I can reccommend that would ease his pain? On a more general note, it seems rather strange that I can't quickly google and

Re: [Tutor] Explanation of Lists data Type

2006-04-12 Thread Noufal Ibrahim
On Wed, April 12, 2006 2:42 pm, Kaushal Shriyan wrote: list[:] -- Does this mean its list[0:0] ['a', 'b', 'c', 'd', 'e', 'f'] I didnot understood this I remember you once asked another question related to sequence slices and I mentioned the effects of slicing with no indices. You sure

Re: [Tutor] Python tutor

2006-03-29 Thread Noufal Ibrahim
On Wed, March 29, 2006 4:35 am, Anna Ravenscroft wrote: There are several of us on the edupython list who want something like this but it hasn't (to my knowledge) been created yet. The best things out there so far, are livewires, guido von robot, and rur-ple. If you're interested in

Re: [Tutor] Learning Python

2006-03-27 Thread Noufal Ibrahim
On Mon, March 27, 2006 4:39 pm, Kaushal Shriyan wrote: Hi I am a novice in Python, Which is the best source of learning python for a beginner If you're already a programmer, then the python tutorial at http://docs.python.org/tut/tut.html + a working python installation is enough IMHO. If

[Tutor] Python tutor

2006-03-27 Thread Noufal Ibrahim
Greetings all, Are there any programs for python that offer an interactive tutorial? Something on the lines of the builtin emacs tutorial (which is basically just a buffer that tells you to try this and try that with itself) or the Inkscape tutorial (which is an SVG document that comes along

Re: [Tutor] Hi

2006-03-21 Thread Noufal Ibrahim
On Wed, March 22, 2006 12:11 pm, Kaushal Shriyan wrote: Hi I am new to python and I am going through the URL http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going through the Chapter 7 Strings, I am stuck with understanding slice which is a part of a String, I am not able

Re: [Tutor] Test If File System is mounted in Linux

2006-03-17 Thread Noufal Ibrahim
On Fri, March 17, 2006 1:06 pm, fortezza-pyt wrote: If there a semi-standard way to test if a file system has been mounted or not using Python? In the Linux command line, I can type mount and see all mounted file system, and then see if the one I am looking for is in the list. While I could