Re: Is this a good idea or a waste of time?

2006-08-28 Thread Simon Forman
Antoon Pardon wrote: On 2006-08-28, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Antoon Pardon wrote: There seem to be enough problems that work with ints but not with floats. In such a case enforcing that the number you work with is indeed an int seems fully appropiate. I've _never_

Re: import function from user defined modules

2006-08-27 Thread Simon Forman
groves wrote: Can anybody give me an example of how to import a function of module X in module y. And please if yu can use classes(Object oriented approach) would be great. The problem is that I have created a text on canvas, and now I want that whenever a user right clicks on it, the option

Re: Newbie Question. Class definitions on the fly.

2006-08-27 Thread Simon Forman
ishtar2020 wrote: Hi everyone I'm sure this question is kinda stupid and has been answered a few times before... but I need your help! I'm writing a small application where the user can analyze some text based on a set of changing conditions , and right now I'm stuck on a point where I'd

Re: eval() woes

2006-08-27 Thread Simon Forman
rdrink wrote: n.n.h. (noob needs help) Ok, I've been beating my head against this for a day... time to ask others. To explain things as simply as possible: I am trying to use eval() to evaluate some simple equations, such as-- pow(AB,2) pow(AB,2)+A pow(A+B,2) pow(A+B,2)+A and so forth...

Re: Segmentation Fault

2006-08-27 Thread Simon Forman
pycraze wrote: I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our testcases we experiance Segmentation fault from the python libraries. If i know how to

Re: Middle matching - any Python library functions (besides re)?

2006-08-27 Thread Simon Forman
Paul Rubin wrote: EP [EMAIL PROTECTED] writes: Given that I am looking for matches of all files against all other files (of similar length) is there a better bet than using re.search? The initial application concerns files in the 1,000's, and I could use a good solution for a number of

Re: rollover effect

2006-08-26 Thread Simon Forman
groves wrote: hi I am trying to get a roll over effect on my canvas.(this is a virtual program which will eventually fit into my final program) Exactly i have a text on my screen and I want to have a brief discription across it whenever the user takes the mouse on it n hence giving

Re: Out-dated compiled modules (*.pyc)?

2006-08-26 Thread Simon Forman
Anastasios Hatzis wrote: Hi folks, how can I prevent Python from adding or using *.pyc files if executing a Python module? I have the strong feeling that the interpreter uses out-dated pyc file instead more recent py files. At least I already had some cases where application behaviour

Re: rollover effect

2006-08-26 Thread Simon Forman
groves wrote: Simon Forman wrote: groves wrote: hi I am trying to get a roll over effect on my canvas.(this is a virtual program which will eventually fit into my final program) Exactly i have a text on my screen and I want to have a brief discription across it whenever

Re: rollover effect

2006-08-26 Thread Simon Forman
groves wrote: Sorry, as I am new to python so couldn't understand what yu were asking. Now the problem is that i annot use pmw in my project..is thre anyother alternative by which I can have a rollover mouse effect on the canvas. thanks Not a problem. Although IDE and GUI are terms that are

Re: rollover effect

2006-08-26 Thread Simon Forman
SuperHik wrote: groves wrote: Simon Forman wrote: groves wrote: Sorry, as I am new to python so couldn't understand what yu were asking. Now the problem is that i annot use pmw in my project..is thre anyother alternative by which I can have a rollover mouse effect on the canvas

Re: Dive into Python question

2006-08-26 Thread Simon Forman
Fred C. Dobbs wrote: I feel like an idiot. I'm going thru Dive Into Python and running the first program - odbchelper.py My output is pwd=secret;database=master;uid=sa;server=mpilgrim which has all the substrings reversed from the output documented in the book. I've run the downloaded code

Re: lazy arithmetic

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: Gabriel Genellina wrote: At Friday 25/8/2006 00:36, [EMAIL PROTECTED] wrote: # This is what I have in mind: class Item(object): def __add__(self, other): return Add(self, other) And this works fine... why make thinks complicated? Yes, I agree

Re: lazy arithmetic

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: Simon Forman wrote: Item.__add__ = Add is a very strange thing to do, I'm not surprised it didn't work. Yes it is strange. I also tried this even stranger thing: class Item(object): class __add__(object): def __init__(self, a, b=None): print

Re: Is this a good idea or a waste of time?

2006-08-25 Thread Simon Forman
asincero wrote: Would it be considered good form to begin every method or function with a bunch of asserts checking to see if the parameters are of the correct type (in addition to seeing if they meet other kinds of precondition constraints)? Like: def foo(a, b, c, d): assert

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: lets say you want a generic numerical algorithom like sum Ruby def sum lst lst.inject(0){|total,current| total*current} end Java // i dont know if there is a numeric super class for numbers class Sum{ public static int sum(int[] lst){ int total = 0;

Re: List comparison help please

2006-08-25 Thread Simon Forman
Bucco wrote: Simon Forman wrote: 1) Don't use dir, file, and list as variable names, those are already python built in objects (the dir() function, list type, and file type, respectively.) Thanks. My own stupidity on this one. 2) 'r' is the default for open(), omit it. self.flist

Re: Fw: Is this a good idea or a waste of time?

2006-08-25 Thread Simon Forman
Hendrik van Rooyen wrote: Simon Forman [EMAIL PROTECTED] wrote: 8- | BTW, speaking of strictness, more stricter is invalid English, | just stricter is the correct form. ;-) or alternatively the construct more strict is also

Re: Duck typing alows true polymorfisim

2006-08-25 Thread Simon Forman
[EMAIL PROTECTED] wrote: What was i thinkinng repace * with + i was'nt thinking i origanaly thaught of sum of squares so i put a * insted of a + But again, what's your question? -- http://mail.python.org/mailman/listinfo/python-list

Re: Avoiding if..elsif statements

2006-08-25 Thread Simon Forman
unexpected wrote: I have a program where based on a specific value from a dictionary, I call a different function. Currently, I've implemented a bunch of if..elsif statements to do this, but it's gotten to be over 30 right now and has gotten rather tedious. Is there a more efficient way to do

Re: When is a subclass not right?

2006-08-24 Thread Simon Forman
Chaz Ginger wrote: I was writing some code that used someone else class as a subclass. He wrote me to tell me that using his class as a subclass was incorrect. I am wondering under what conditions, if ever, does a class using a subclass not work. Here is an example. For instance the original

Re: Python editor

2006-08-24 Thread Simon Forman
Jason Jiang wrote: Hi, Could someone recommend a good Python editor? Thanks. Jason There have just been one or two long-ish threads on exactly this question. Search the google groups version of this group for them. Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: lazy arithmetic

2006-08-24 Thread Simon Forman
[EMAIL PROTECTED] wrote: # This is what I have in mind: class Item(object): def __add__(self, other): return Add(self, other) class Add(Item): def __init__(self, a, b): self.a = a self.b = b a = Item() b = Item() c = a+b # Now, I am going absolutely crazy with this

Re: RE Module

2006-08-24 Thread Simon Forman
Roman wrote: I am trying to filter a column in a list of all html tags. What? To do that, I have setup the following statement. row[0] = re.sub(r'.*?', '', row[0]) The results I get are sporatic. Sometimes two tags are removed. Sometimes 1 tag is removed. Sometimes no tags are removed.

Re: Python-like C++ library

2006-08-23 Thread Simon Forman
Will McGugan wrote: Hi folks, I'm forced to use C++ and STL at work, and consequently miss the ease of use of Python. I was wondering if there was a C++ library that implemented the fundamental objects of Python as close as possible, perhaps using STL underneath the hood. Too clarify, Im

Re: Regex help...pretty please?

2006-08-23 Thread Simon Forman
MooMaster wrote: I'm trying to develop a little script that does some string manipulation. I have some few hundred strings that currently look like this: cond(a,b,c) and I want them to look like this: cond(c,a,b) but it gets a little more complicated because the conds themselves may

Re: setting a breakpoint in the module

2006-08-23 Thread Simon Forman
Jason Jiang wrote: Hi, I have two modules: a.py and b.py. In a.py, I have a function called aFunc(). I'm calling aFunc() from b.py (of course I import module a first). The question is how to directly set a breakpoint in aFunc(). The way I'm doing now is to set a breakpoint in b.py at the

Re: setting a breakpoint in the module

2006-08-23 Thread Simon Forman
Jason Jiang wrote: Simon Forman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Jason Jiang wrote: Hi, I have two modules: a.py and b.py. In a.py, I have a function called aFunc(). I'm calling aFunc() from b.py (of course I import module a first). The question is how

Re: range of int() type.

2006-08-23 Thread Simon Forman
KraftDiner wrote: What is the range of a variable of type int() eg: i = int() print i.max() # 0x print i.min() # 0x is it a signed 16 bit or 32 bit or is it unsigned 16 or 32... I've noticed that it can be incremented into a new class of type long... | import sys |

Re: Problem with tokenize module and indents

2006-08-23 Thread Simon Forman
Tim wrote: I ran into a problem with a script i was playing with to check code indents and need some direction. It seems to depend on if tabsize is set to 4 in editor and spaces and tabs indents are mixed on consecutive lines. Works fine when editors tabsize was 8 regardless if indents are

Re: how to get file name of the running .py file

2006-08-23 Thread Simon Forman
Larry Bates wrote: Jason Jiang wrote: Hi, How to get the name of the running .py file like the macro _FILE_ in C? Thanks. Jason import os import sys print sys.argv[0] or if you just want the script and not the full path print os.path.basename(sys.argv[0]) -Larry Bates

Re: setting a breakpoint in the module

2006-08-23 Thread Simon Forman
Jason Jiang wrote: Great! It's working now. Thank you so much. Jason You're welcome, it's a pleasure! :-D ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: swapping numeric items in a list

2006-08-22 Thread Simon Forman
Jiang Nutao wrote: Hi, I simplify my problem like below To convert list aa = [0x12, 0x34, 0x56, 0x78] into [0x34, 0x12, 0x78, 0x56] How to do it fast? My real list is huge. Thanks a lot. Jason Here's simple and probably fast enough way (but it won't work right on odd length

Re: key not found in dictionary

2006-08-22 Thread Simon Forman
Or you can use the has_key() and test it first. For example if foo.has_key('bar'): print 'we have it' else : print 'we don't have bar.' Nowadays you can also say: if 'bar' in foo: # do something -- http://mail.python.org/mailman/listinfo/python-list

Re: [NEWB]: List with random numbers

2006-08-20 Thread Simon Forman
eltower wrote: Hey all, I'm trying to write a program in Python for learning purposes which is meant to: Generate a random number from 0 to 6 Insert this random number to the end of a list unless the number is already there finish with a len(list) = 7 so far, I have this: import

Re: Access to sys.argv when python interpreter is invoked in some modes like 'python -c command'

2006-08-20 Thread Simon Forman
[EMAIL PROTECTED] wrote: The python tutorial says When the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'. When -c command is used, sys.argv[0] is set to '-c'. but when we use a command say 'python -c command' where can we access sys.argv (are there some

Re: List comparison help please

2006-08-20 Thread Simon Forman
Bucco wrote: I am trying to compare a list of items to the list of files generated by os.listdir. I am having trouble getting this to work and think I may be going down the wrong path. Please let me know if hter is a better way to do this. THis is what I have for my class so far: import

Re: string validation/ form validation

2006-08-20 Thread Simon Forman
OriginalBrownster wrote: Hi there: I just had a quick thought of something that might be useful to me when creating my web app and I wanted some help on the idea; since this group has been helpful in the past. in my app I have a few html forms that require the user to enter in data, in

Re: text editor suggestion?

2006-08-18 Thread Simon Forman
John Salerno wrote: Ok, I know it's been asked a million times, but I have a more specific question so hopefully this won't be just the same old post. I've tried a few different editors, and I really like UltraEdit, but it's Windows-only and I'm working more on Linux nowadays. Here are my

Re: text editor suggestion?

2006-08-18 Thread Simon Forman
Paul Rubin wrote: Simon Forman [EMAIL PROTECTED] writes: Have you tried IDLE? It ships with python, meets your 5 criteria(*), can be customized (highlighting colors and command keys and more), and includes a usable GUI debugger. It's got some warts, but I like it a lot, it's pretty much

Re: round not rounding to 0 places

2006-08-16 Thread Simon Forman
Fuzzydave wrote: I have been using a round command in a few places to round a value to zero decimal places using the following format, round('+value+', 0) but this consistantly returns the rounded result of the value to one decimal place with a zero EG: 4.97 is returned as 5.0 when i

Re: Python form Unix to Windows

2006-08-16 Thread Simon Forman
Pradeep wrote: Hi friends, We are changing the python application from Unix to Windows. The source code of Python application should work well in windows. How to make changed to windows environment. In Python code we have login module, ftp, socket programming. Please help in changing the

Re: Very weird behavior that's driving me crazy

2006-08-16 Thread Simon Forman
Pupeno wrote: Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print getStatus(self=%s) % self return {a: b, c: d} and then I have another module called

Re: what is the keyword is for?

2006-08-16 Thread Simon Forman
Sybren Stuvel wrote: Dan Bishop enlightened us with: a = b = 1e1000 / 1e1000 a is b True a == b False If a is b then they refer to the same object, hence a == b. It cannot be otherwise, unless Python starts to defy logic. I copied your code and got the expected result: a = b =

Re: how to deepcopy a slice object?

2006-08-16 Thread Simon Forman
Alexandre Guimond wrote: thx for all the help simon. good ideas i can work with. thx again. alex. You're very welcome, a pleasure. ;-) ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-16 Thread Simon Forman
John Machin wrote: Simon Forman wrote: | class f: ... def __init__(self): ... del self Of course nothing happens. Args are local variables. 'self' is is a vanilla arg of a vanilla function. I know. ... | e = f() | e __main__.f instance at 0xb7dd91ec

Re: Documentation Question About Depricated String Functions

2006-08-16 Thread Simon Forman
Hitesh wrote: Hi, In python doc -- 4.1.4 Deprecated string functions -- I read that The following list of functions are also defined as methods of string and Unicode objects; see ``String Methods'' (section 2.3.6) for more information on those. You should consider these functions as

Re: trouble understanding inheritance...

2006-08-16 Thread Simon Forman
KraftDiner wrote: Fredrik Lundh wrote: KraftDiner wrote: This is not working the way I think it should it would appear that fromfile and getName are calling the baseClass methods which are simple passes What have I done wrong? class baseClass: def __init__(self,

Re: getting database column names from query

2006-08-16 Thread Simon Forman
Jason Nordwick wrote: I'm using MySQLdb and can connect and issue queries that return result sets, but I how do I get the column names for those result sets? c = MySQLdb.connect(*creds) k = c.cursor() k.execute(select * from account) 3L k.fetchall() ((1L, 'test', -1L), (2L, 'Test',

Re: Anyone have a link handy to an RFC 821 compliant email address regex for Python?

2006-08-16 Thread Simon Forman
fuzzylollipop wrote: I want to do email address format validations, without turning to ANTLR or pyparsing, anyone know of a regex that is COMPLIANT with RFC 821. Most of the ones I have found from google searches are not really as robust as I need them to be. Would email.Utils.parseaddr() fit

Re: Mega Newbie Questions: Probably FAQs

2006-08-15 Thread Simon Forman
Zeph wrote: Python Pros: Free. Open source. Deep. Flexible. Rich community and third party stuff. Well documented. Cons: Interpreted. Unknown: Secure (meaning not easily reverse engineered) code? Performance? Very recent thread on this subject:

Re: how to deepcopy a slice object?

2006-08-15 Thread Simon Forman
Alexandre Guimond wrote: Hi all, i'm trying to deepcopy a slice object but i get the following error. Does anyone know a workaround? ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on Python 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)] on win32 Type help,

Re: how to deepcopy a slice object?

2006-08-15 Thread Simon Forman
going to 3D and 4D grid, and its somewhat annoying to carry so many indices in my class definition. Simon Forman wrote: Alexandre Guimond wrote: Hi all, i'm trying to deepcopy a slice object but i get the following error. Does anyone know a workaround? ActivePython 2.4.3

Re: how to deepcopy a slice object?

2006-08-15 Thread Simon Forman
Duncan Booth wrote: Simon Forman wrote: Why would you want to [deep]copy a slice object? I would guess the original poster actually wanted to copy a data structure which includes a slice object somewhere within it. That is a perfectly reasonable albeit somewhat unusual thing to want

Re: using python at the bash shell?

2006-08-15 Thread Simon Forman
cga2000 wrote: On Tue, Aug 08, 2006 at 12:22:42PM EDT, Simon Forman wrote: John Salerno wrote: [EMAIL PROTECTED] wrote: John Aside from the normal commands you can use, I was wondering if John it's possible to use Python from the terminal instead of the John normal

Re: idea on how to get/set nested python dictionary values

2006-08-15 Thread Simon Forman
[EMAIL PROTECTED] wrote: | would use a recursive approach for this - given that you have a sort of recursive datastructure: py def SetNewDataParam2(Data, NewData): ... if type(Data[Data.keys()[0]]) == type(dict()): Note: | type(dict()) is dict True dict *is* a type... --

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread Simon Forman
tobiah wrote: I should have made it more clear that Foo is a class: class Foo: def __init__(self, *args): for arg in args: if is_fruit(arg): del(self) tobiah wrote: Suppose I do: myfoo = Foo('grapes',

Re: yEnc

2006-08-15 Thread Simon Forman
Kairo Matthias wrote: How can i encode with yEnc? What's yEnc? :-) Seriously though, did you try googling for yEnc python? Peace, ~Simon -- http://mail.python.org/mailman/listinfo/python-list

Re: programming with Python 3000 in mind

2006-08-15 Thread Simon Forman
[EMAIL PROTECTED] wrote: Some basic syntax such as print hello world is going away to make print look like a function. IMO, fixing what is not broken because of the aesthetic tastes of the BDFL is a bad idea. His reasoning is at

Re: Printing n elements per line in a list

2006-08-15 Thread Simon Forman
unexpected wrote: If have a list from 1 to 100, what's the easiest, most elegant way to print them out, so that there are only n elements per line. So if n=5, the printed list would look like: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 etc. My search through the previous posts yields methods

Re: Printing n elements per line in a list

2006-08-15 Thread Simon Forman
John Machin wrote: Steven D'Aprano wrote: I think it's possible to hack it up using while loops and some ugly slicing, but hopefully I'm missing something I don't see why you think that's an ugly hack. def printitems(sequence, count=5): Print count items of sequence per

Re: outputting a command to the terminal?

2006-08-14 Thread Simon Forman
John Salerno wrote: Yu-Xi Lim wrote: I assume you're using a Debian-based distro with aptitude as the front end. In which case, all dpkg operations should be logged in /var/log/dpkg.log Yes, I'm using Ubuntu. But I checked this log file and I'm a bit confused. It has a lot of listings

Re: outputting a command to the terminal?

2006-08-14 Thread Simon Forman
John Salerno wrote: Simon Forman wrote: It's simple, short, and to-the-point. The equivalent python script would be much longer, for no appreciable gain. I write most of my tiny little helper scripts in python, but in this case, bash is the clear winnar. (And on *nix. man pages

Re: Memory problem

2006-08-14 Thread Simon Forman
Yi Xing wrote: On a related question: how do I initialize a list or an array with a pre-specified number of elements, something like int p[100] in C? I can do append() for 100 times but this looks silly... Thanks. Yi Xing You seldom need to do that in python, but it's easy enough:

Re: reading from sockets

2006-08-13 Thread Simon Forman
AndrewTK wrote: Simon Forman wrote: So I'm guessing it's something wrong in your java server. Thanks then. I'll keep testing then... Although I don't seem to have netcat on my unit... I'm using a uni computer so I can't install stuff... but I'm guessing what I wrote is something like

Re: open() and Arabic language

2006-08-13 Thread Simon Forman
MaaSTaaR wrote: Hello ... firstly , sorry for my bad English . i have problem with open() function when i use it with file which name in Arabic , the open() will not find the file , and i am sure the file is exist . so how i can solve this problem ? On this page

Re: yet another noob question

2006-08-13 Thread Simon Forman
mike_wilson1333 wrote: I would like to generate every unique combination of numbers 1-5 in a 5 digit number and follow each combo with a newline. So i'm looking at generating combinations such as: (12345) , (12235), (4) and so on. What would be the best way to do this? So, basically i'm

Re: yet another noob question

2006-08-13 Thread Simon Forman
Stargaming wrote: Stargaming schrieb: mike_wilson1333 schrieb: I would like to generate every unique combination of numbers 1-5 in a 5 digit number and follow each combo with a newline. So i'm looking at generating combinations such as: (12345) , (12235), (4) and so on. What

Re: looking for a simple way to load a program from another python program..

2006-08-13 Thread Simon Forman
[EMAIL PROTECTED] wrote: I was looking for a simple way to load a simple python program from another python program. I tried os.system(cabel) The file name is cabel.py a csound instrument editor.. The error I am getting is Traceback (most recent call last): File

Re: Nested if and expected an indent block

2006-08-13 Thread Simon Forman
[EMAIL PROTECTED] wrote: Dustan wrote: To see the full traceback, assuming you're using windows, you need to run it on the Command prompt. Hi Dustan: Here's the traceback: C:\docs\PythonSylloSolver.py File C:\docs\Python\SylloSolver.py, line ^ IndentationError:

Re: iterator wrapper

2006-08-12 Thread Simon Forman
alf wrote: Simon Forman wrote: | I = ([n] for n in i) This is nice but I am iterating thru hude objects (like MBs) so you know ... No, I don't know... :-) potentially my source lists are huge - so wanted to avoid unnecessary memory allocation My friend, I think you've

Re: reading from sockets

2006-08-12 Thread Simon Forman
AndrewTK wrote: I'm assuming that your server waits to receive the word 'hello' before replying with the three strings (first, second, and third)? So once your Nope - actually it's a threaded server, with the main thread simply dumping network input to the console and command line input

Re: trouble with replace

2006-08-12 Thread Simon Forman
f pemberton wrote: Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], f pemberton wrote: I've tried using replace but its not working for me. xdata.replace('abcdef', 'highway') xdata.replace('defgef', 'news') xdata.replace('effwer', 'monitor') `replace()` does not work in

Re: self=pickle.load(file)? (Object loads itself)

2006-08-12 Thread Simon Forman
Anton81 wrote: Hi! it seems that class Obj: def __init__(self): f=file(obj.dat) self=pickle.load(f) ... doesn't work. Can an object load itself with pickle from a file somehow? What's an easy solution? Anton Why are you trying to do this?

Re: trouble with replace

2006-08-12 Thread Simon Forman
Simon Forman wrote: f pemberton wrote: Marc 'BlackJack' Rintsch wrote: In [EMAIL PROTECTED], f pemberton wrote: I've tried using replace but its not working for me. xdata.replace('abcdef', 'highway') xdata.replace('defgef', 'news') xdata.replace('effwer', 'monitor

Re: sys.platform documentation?

2006-08-11 Thread Simon Forman
| platform.platform() 'Linux-2.6.15-26-386-i686-with-debian-testing-unstable' | platform.uname() ('Linux', 'garbage', '2.6.15-26-386', '#1 PREEMPT Thu Aug 3 02:52:00 UTC 2006', 'i686', '') Ubuntu 6.06 LTS - the Dapper Drake - released in June 2006. [EMAIL PROTECTED]:~ $ cat /proc/cpuinfo

Re: iterator wrapper

2006-08-11 Thread Simon Forman
John Machin wrote: alf wrote: Hi, I have a following task: let's say I do have an iterator returning the some objects: i=iterator i.next() 1 i.next() 'abgfdgdfg' i.next() some object For some reason I need to wrap thos objects with a list. I thought I could

Re: iterator wrapper

2006-08-11 Thread Simon Forman
alf wrote: Simon Forman wrote: class LW(object): # ListWrapper ... def __init__(self, i): ... self.theiter = i ... def next(self): ... return [self.theiter.next()] I hoped one lamda would take care of it but looks like it is a simplest choice. | I = ([n] for n

Re: sys.platform documentation?

2006-08-10 Thread Simon Forman
Michiel Sikma wrote: Op 10-aug-2006, om 13:00 heeft Tim Golden het volgende geschreven: Michiel Sikma wrote: Hello everybody, I was thinking about making a really insignificant addition to an online system that I'm making using Python: namely, I would like it to print the platform

Re: String Formatting

2006-08-10 Thread Simon Forman
OriginalBrownster wrote: Hi there: I was wondering if its at all possible to search through a string for a specific character. I want to search through a string backwords and find the last period/comma, then take everything after that period/comma Example If i had a list:bread,

Re: reading from sockets

2006-08-10 Thread Simon Forman
AndrewTK wrote: Hello, I'm trying to read data from a socket and I'm not seeing what I'm expecting it seems to skip the first line of data. I am new to Python and just trying to test what I can do with it... and it's not looking pretty. I have some Python code:

Re: draw an image in wx.BufferedDC onto the page created by AddPage of wx.Notebook

2006-08-10 Thread Simon Forman
zxo102 wrote: Hi everyone, I have tried two days to figure out how to draw the image in wx.BufferedDC on the page created by AddPage of wx.Notebook but still got no clue. The attached example works fine. If I click the menu Draw -- New Drawing. The image with

Re: seaching a list...

2006-08-10 Thread Simon Forman
bruce wrote: hi... i'm playing with a test sample. i have somethhing like: dog = mysql_get(.) . . . such that 'dog' will be an 'AxB' array of data from the tbls What's an 'AxB' array, do you mean a list of lists? If not, what kind of object do you mean and what methods does it

Re: win32 load icon not from file, but from something

2006-08-10 Thread Simon Forman
GHUM wrote: I have found a make a icon in traybar skript, and it loads its Icon from a file hinst = win32gui.GetModuleHandle(None) iconPathName= c:/myapp/myapp.ico icon_flags = win32con.LR_LOADFROMFILE | win32con.LR_DEFAULTSIZE hicon = win32gui.LoadImage(hinst, str(iconPathName),

Re: converting a nested try/except statement into try/except/else

2006-08-10 Thread Simon Forman
John Salerno wrote: Simon Forman wrote: What about the version I gave you 8 days ago? ;-) http://groups.google.ca/group/comp.lang.python/msg/a80fcd8932b0733a It's clean, does the job, and doesn't have any extra nesting. Peace, ~Simon I remember that version, but I found

Re: error handling

2006-08-10 Thread Simon Forman
Chris wrote: I want to handle errors for a program i'm building in a specific way, but I don't want to use try/except/finally because it requires forming new blocks of code. I want to be able things like this: a = [2, 423, brownie, 234.34] try: a[890] except IndexError: # I don't use

Re: easy string formating question

2006-08-10 Thread Simon Forman
Slawomir Nowaczyk wrote: On Thu, 10 Aug 2006 11:39:41 -0700 f pemberton [EMAIL PROTECTED] wrote: # I have kind of an interesting string, it looks like a couple hundred # letters bunched together with no spaces. Anyway, i'm trying to put a # ? and a (\n) newline after every 100th character

Re: hide python code !

2006-08-10 Thread Simon Forman
Bayazee wrote: hi in compiled languages when we compile a code to an executable file it convert to a machine code so now we cant access to source ... It can still be disassembled and reverse engineered. but in python we easily open the program executable(ascii) file and read source i

Re: Python share CPU time?

2006-08-10 Thread Simon Forman
Yannick wrote: Thank you all for the detailled answers. What I would like to achieve is something like: # main loop while True: for robot in robots: robot.start() robot.join(0.2) # wait 200ms if robot.is_active(): robot.stop() # run all the

Re: converting a nested try/except statement into try/except/else

2006-08-09 Thread Simon Forman
John Salerno wrote: I'm starting out with this: try: if int(text) 0: return True else: self.error_message() return False except ValueError: self.error_message() return False I rewrote it as this: try: int(text) except

Re: Eval (was Re: Question about using python as a scripting language)

2006-08-09 Thread Simon Forman
Chris Lambacher wrote: On Wed, Aug 09, 2006 at 11:51:19AM -0400, Brendon Towle wrote: On 9 Aug 2006, at 11:04 AM, Chris Lambacher wrote: How is your data stored? (site was not loading for me). In the original source HTML, it's like this (I've deleted all but the

Re: binary conversion issues

2006-08-08 Thread Simon Forman
godavemon wrote: I'm using python's struct and binascii modules to write some values from my parser to binary floats. This works great for all of my binary files except one. For some reason this file is saving to 836 (stated by my command shell) bytes instead of 832 like it should. It

Re: using python at the bash shell?

2006-08-08 Thread Simon Forman
John Salerno wrote: [EMAIL PROTECTED] wrote: John Aside from the normal commands you can use, I was wondering if John it's possible to use Python from the terminal instead of the John normal bash commands (e.g. print instead of echo). Take a look at ipython

Re: Newbie question: what's with self?

2006-08-08 Thread Simon Forman
donkeyboy wrote: This is probably a really basic question, but anyway ... I'm new to both Python and OO programming. From looking at a number of code examples, the word self is used a lot when referring to classes. As such, what does self mean and/or do? I've read things that say it's a

Re: String.digits help!!!

2006-08-08 Thread Simon Forman
Anoop wrote: Hi All Hope u all might have come across the string deprecation thought of in Python 3.0. For example : string.lower(str) needs to be some thing like str.lower(). Can some one help me out whether such a change in the common python would require string.digits to be changed.

Re: String.digits help!!!

2006-08-08 Thread Simon Forman
[EMAIL PROTECTED] wrote: Simon Forman: It's unlikely to be deprecated since it doesn't make much sense to make it an attribute of the str type. Why? Thank you, bearophile Let me toss the question back at you: Does it make sense to you that str should have this attribute? Why? I'm

Re: (easy question) Find and replace multiple items

2006-08-08 Thread Simon Forman
ds4ff1z wrote: Hello, i'm looking to find and replace multiple characters in a text file (test1). I have a bunch of random numbers and i want to replace each number with a letter (such as replace a 7 with an f and 6 with a d). I would like a suggestion on an a way to do this. Thanks

Re: newb question: file searching

2006-08-08 Thread Simon Forman
[EMAIL PROTECTED] wrote: hiaips wrote: [EMAIL PROTECTED] wrote: I'm new at Python and I need a little advice. Part of the script I'm trying to write needs to be aware of all the files of a certain extension in the script's path and all sub-directories. Can someone set me on

Re: Class data being zapped by method

2006-08-08 Thread Simon Forman
Kevin M wrote: Figures. I'll try to complicate it sufficiently ;) [edit] I was going to try to sum up what goes on, but I realized that I was retyping what I already programmed in an effort to better illustrate exactly what I'm doing. Pastebin it is. Don't fear, it's only around 200 lines

Re: How to reverse tuples in a list?

2006-08-08 Thread Simon Forman
Noah wrote: I have a list of tuples [('a', 1.0), ('b', 2.0), ('c', 3.0)] I want to reverse the order of the elements inside the tuples. [(1.0,'a'), (2.0, 'b'), (3.0, 'c')] I know I could do this long-form: q = [] y = [('a', 1.0), ('b', 2.0), ('c', 3.0)] for i in y:

<    1   2   3   4   5   >