Re: class objects, method objects, function objects

2007-03-18 Thread 7stud
Darn. I made some changes to the class and I didn't change the function object. It should be: | V function object - | def sayHi(self): | | print "Hello " + self.name| |_| --

Re: * operator--as in *args?

2007-03-19 Thread 7stud
On Mar 18, 7:52 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > def f(*args, **kw): > > ... print "args",args > ... print "kw",kw > ...>>> d = {"a":1, "b":2, "c":3} > >>> f(**d) > Whoa! **? And applied to a function parameter? Back to the drawing board. On Mar 18, 7:21 pm, [EMAIL PROTEC

Re: class objects, method objects, function objects

2007-03-19 Thread 7stud
Hi, Thanks for the responses. I understand that python automatically sends 'self' to a member function, i.e. self gets prepended to the argument list. I guess I am having trouble with this statement: When the method object is called with an argument list, it is unpacked again, a new argumen

Re: class objects, method objects, function objects

2007-03-20 Thread 7stud
Thanks Duncan and Dennis. -- http://mail.python.org/mailman/listinfo/python-list

Re: Imports

2007-03-20 Thread 7stud
On Mar 20, 12:51 pm, [EMAIL PROTECTED] wrote: > I typically just import sys and then do a > sys.path.append(directoryPath). This basically makes whatever modules > in that path available at run time. If you need a beginners reference > book, I recommend "Beginning Python" by Hetland. "Python Progra

Re: Imports

2007-03-20 Thread 7stud
On Mar 20, 6:33 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Mar 20, 12:51 pm, [EMAIL PROTECTED] wrote: > > > I typically just import sys and then do a > > sys.path.append(directoryPath). This basically makes whatever modules > > in that path available at run

Re: On Java's Interface (the meaning of interface in computer programing)

2007-03-20 Thread 7stud
No. -- http://mail.python.org/mailman/listinfo/python-list

dictionary.copy()?

2007-03-20 Thread 7stud
Here is some example code: d = {"a":"hello", "b":[1, 2, 3]} x = d.copy() d["b"][0]=10 print x output: {'a': 'hello', 'b': [10, 2, 3]} It looks like the key names of a dictionary store pointers to the values? Or does a dictionary object manage pointers to keys and values, so copy() above just c

Re: Printing from a text file quirk

2007-03-22 Thread 7stud
On Mar 22, 9:34 pm, [EMAIL PROTECTED] wrote: > self.headertxt = open("pages/header.html","r") > > *** Irrelevant code omitted *** > > headerp1 = "" > for i in range(5): > headerp1 += self.headertxt.readline() > headerp2 = self.headertxt.readline(7) > headerp3 = self.headertxt.readline() > h

Re: "finally" for unit test

2007-03-23 Thread 7stud
On Mar 23, 5:18 am, "killkolor" <[EMAIL PROTECTED]> wrote: > I have .. a single function that .. > works with files (takes input and outputs in the same file, no return > values). That function could cause problems. If your function reads in the whole file, modifies the data, and then overwrites

Re: Join strings - very simple Q.

2007-03-24 Thread 7stud
On Mar 24, 8:30 am, Duncan Booth <[EMAIL PROTECTED]> wrote: > In case you are feeling that the ','.join(l) looks a bit jarring, be aware > that there are alternative ways to write it. You can call the method on the > class rather than the instance: > >jl = str.join(',', l) >jl = unicode.joi

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
Hi, Robert Hicks wrote: > I want to upgrade to 2.5 but I don't see any unistall instructions > anywhere. > > Robert I don't know if this is pertinent to your situation, but yesterday I read something that said you need a "framework" install in order to do GUI programming with wxPython. I believ

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
Robert Hicks wrote: >... but I don't see any unistall instructions > anywhere. > Did 2.4.4 come pre-installed? -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
On Mar 24, 12:09 pm, "Greg Donald" <[EMAIL PROTECTED]> wrote: > On 24 Mar 2007 10:30:28 -0700, Robert Hicks <[EMAIL PROTECTED]> wrote: > > > I want to upgrade to 2.5 but I don't see any unistall instructions > > anywhere. > > You're not required to remove the old version before installing the new

Re: Python object overhead?

2007-03-24 Thread 7stud
On Mar 23, 4:04 pm, Jack Diederich <[EMAIL PROTECTED]> wrote: > > If you make the record a new style class (inherit from object) you can > specify the __slots__ attribute on the class. This eliminates the per > instance dictionary overhead in exchange for less flexibility. > How is efficiency imp

Re: Python object overhead?

2007-03-24 Thread 7stud
On Mar 24, 2:19 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > Only one list is created. It is used to define a C array where attributes > will be stored. Each instance still has that C array, but it has much less > overhead than a Python list or dictionary. > It's all C underneath, right?

functions, classes, bound, unbound?

2007-03-24 Thread 7stud
Here is some example code that produces an error: class Test(object): def greet(): print "Hello" t = Test() t.greet() TypeError: greet() takes no arguments (1 given) Ok. That makes sense. t.greet() is a "bound method", so something automatically relays the instance obje

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
On Mar 24, 8:18 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > On Mar 24, 2007, at 12:30 PM, Robert Hicks wrote: > > > I want to upgrade to 2.5 but I don't see any unistall instructions > > anywhere. > > Don't uninstall it. > > That's why Apple put python under /Library/Frameworks/ > Python.frame

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
On Mar 24, 9:40 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Mar 24, 8:18 pm, Michael Bentley <[EMAIL PROTECTED]> wrote: > > > On Mar 24, 2007, at 12:30 PM, Robert Hicks wrote: > > > > I want to upgrade to 2.5 but I don't see any unistall in

Re: Removing Python 2.4.4 on OSX

2007-03-24 Thread 7stud
On Mar 24, 10:04 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: 1462 Feb 20 14:31 .. > > Try /System/Library/Frameworks ... > > Alex There it is. I notice there is a directory: /Python.framework/ Versions/2.3/Mac/Tools/IDE which has a bunch of files in it. Do Macs have some kind of pre- instal

Re: functions, classes, bound, unbound?

2007-03-24 Thread 7stud
> ...classes don't invoke the function directly, they convert it to > an 'unbound method' object:: > > >>> class Test(object): > ... def greet(): > ... print 'Hello' > ... > >>> Test.greet > > >>> Test.greet() > Traceback (most recent call last):

Re: functions, classes, bound, unbound?

2007-03-25 Thread 7stud
On Mar 25, 3:00 am, [EMAIL PROTECTED] wrote: > On Mar 25, 9:13 am, "7stud" <[EMAIL PROTECTED]> wrote: > > > MyClass.someFunc > > > Is there some other way to retrieve a user-defined function object > > from a class other than using the class name or a

Re: functions, classes, bound, unbound?

2007-03-26 Thread 7stud
On Mar 25, 3:09 pm, Steven Bethard <[EMAIL PROTECTED]> wrote: > Here's another way of looking at it:: > > >>> class Test(object): > ... pass > ... > >>> def greet(): > ... print 'Hello' > ... >>> Test.greet = greet >>> Test.greet > Interesting. After playi

Re: functions, classes, bound, unbound?

2007-03-26 Thread 7stud
On Mar 26, 5:08 am, Bruno Desthuilliers wrote: > Most of Python's object model is documented here: > > http://www.python.org/download/releases/2.2.3/descrintro/http://users.rcn.com/python/download/Descriptor.htm > Thanks. I've looked at both of those, and the second one is very good. -- http:/

Re: Python object overhead?

2007-03-26 Thread 7stud
On Mar 26, 9:13 am, "Matt Garman" <[EMAIL PROTECTED]> wrote: > On 3/23/07, Jack Diederich <[EMAIL PROTECTED]> wrote: > > > If you make the record a new style class (inherit from object) you can > > specify the __slots__ attribute on the class. This eliminates the per > > instance dictionary overhe

Re: functions, classes, bound, unbound?

2007-03-26 Thread 7stud
On Mar 26, 6:49 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > class Test(object): > pass > def greet(x): > print "hello" > Test.func = greet > print Test.func > t = Test() > print t.func > def sayBye(x): > print "bye" > t.bye = sayBye > print t.bye

Re: Why doesnt __getattr__ with decorator dont call __get_method in decorator

2007-03-28 Thread 7stud
On Mar 28, 8:28 am, "glomde" <[EMAIL PROTECTED]> wrote: > Hi, > > I tried to write a decorator for that should be for methods but for > some reasons > it doens seem to work when you try to do it on the __getattr__ method > in a class. > Could anybody give some hints why this is? > All you have to

manually implementing staticmethod()?

2007-03-28 Thread 7stud
Hi, Can someone show me how to manually implement staticmethod()? Here is my latest attempt: def smethod(func): def newFunc(): pass def newGet(): print "new get" newFunc.__get__ = newGet return newFunc class Tes

Re: manually implementing staticmethod()?

2007-03-30 Thread 7stud
Hi, Thanks for the responses. On Mar 28, 4:01 pm, "Michael Spencer" <[EMAIL PROTECTED]> wrote: > "7stud" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED]> Hi, > > > Can someone show me how to manually imp

Re: re.findall() hangs in python

2007-03-31 Thread 7stud
On Mar 31, 9:12 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following regular expression. > It works when 'data' contains the pattern and I see 'match2' get print > out. > But when 'data' does not contain pattern, it just hangs at > 're.findall' > > pattern = re.compile(

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(self): > > > pass > > > def my_method(self): > > > var

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > On Apr 1, 9:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(self): > > > pass > > > def my_method(self): > > > var

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > asdf1234234 wrote: > > -a.py- > > import b > > > class A: > > def __init__(self): > > pass > > def my_method(self): > > var = 1 > > self.var = 2 > > b.set_var(self) > > print

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 9:24 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 1, 7:43 pm, Michael Hoffman <[EMAIL PROTECTED]> wrote: > > > > > asdf1234234 wrote: > > > -a.py- > > > import b > > > > class A: > > > def __init__(

Re: can a method access/set another's variables?

2007-04-01 Thread 7stud
On Apr 1, 7:56 pm, "wswilson" <[EMAIL PROTECTED]> wrote: > I am parsing a document which contains some lines with code I want to > eval or exec. However, due to the complexity of the parsing, I am > splitting it among different methods. So, if I eval something in one > method, it won't be there if

python on mac os 10.4.x

2007-04-02 Thread 7stud
Hi, Python 2.3.5 comes pre-installed on mac os 10.4.7, and I've looked around in /System/Library/Frameworks/Python.framework/ and under .../ Versions/2.3/bin/, there is an exec file named 'idle'. I assume that is the Python IDLE I've read about, but I can't figure out what I need to do to use IDL

Re: getattr/setattr q.

2007-04-02 Thread 7stud
On Apr 2, 10:08 pm, Paulo da Silva <[EMAIL PROTECTED]> wrote: > Is it possible to use getattr/setattr for variables not inside > classes...? What does the python documentation say about the definition of setattr()? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to have a list of lists (or array of lists)

2007-04-03 Thread 7stud
On Apr 3, 10:12 am, "bahoo" <[EMAIL PROTECTED]> wrote: > Hi, > > I want to have many lists, such as list0, list1, list2, ..., each one > holding different number of items. > Is there something like > list[0] > list[1] > list[2] > > so that I can iterate through this list of lists? > > Thanks! > bah

Re: File Object behavior

2007-04-03 Thread 7stud
On Apr 3, 12:02 pm, Michael Castleton <[EMAIL PROTECTED]> wrote: > When I open a csv or txt file with: > > infile = open(sys.argv[1],'rb').readlines() > or > infile = open(sys.argv[1],'rb').read() > > and then look at the first few lines of the file there is a carriage return > + > line feed at the

Re: File Object behavior

2007-04-03 Thread 7stud
On Apr 3, 12:26 pm, "7stud" <[EMAIL PROTECTED]> wrote: > The file.writelines() documentation says that it > doesn't add line separators. Is adding a carriage return something > different? No. > Is this expected behavior? According to Python in a Nutshell(p.

Re: how to remove multiple occurrences of a string within a list?

2007-04-03 Thread 7stud
On Apr 3, 12:20 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. > > It seems like regular expressions is the rescue, but I couldn't fi

Re: Newbie - needs help

2007-04-03 Thread 7stud
On Apr 3, 2:42 pm, "Anbeyon" <[EMAIL PROTECTED]> wrote: > Hi > > I have not yet programmed in Python but am experienced in a number o > other languages. > > I'd like to start to use Python to develop cross platform applications > but havin kust started to investigate tols, libraries etc I feel a >

heap doesn't appear to work as described

2007-04-03 Thread 7stud
My book says that in a heap, a value at position i will be smaller than the values at positions 2*i and 2*i + 1. To test that, I ran this program: -- from heapq import * from random import shuffle data = range(10) shuffle(data) heap = [] for n in data: heappush(heap, n) print heap

Re: heap doesn't appear to work as described

2007-04-03 Thread 7stud
On Apr 3, 5:27 pm, [EMAIL PROTECTED] wrote: > >> My book says that in a heap, a value at position i will be smaller > >> than the values at positions 2*i and 2*i + 1. > > Check the heapq docs for the constraints the Python heapq module maintains: > >http://docs.python.org/dev/lib/modu

Re: How can I time how much each thread takes?

2007-04-04 Thread 7stud
On Apr 3, 11:00 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following code which spawn a number of thread and do > something (in the run method of MyThread). > how can I record how much time does EACH thread takes to complete the > 'run'? > > for j in range(threadCount

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread 7stud
On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > > target = "0024" > > l = ["0024", "haha", "0024"] > > > > for index, val in enumerate(l): > > if val==target: > > del l[index] > > > print l > > This latter suggestion (with the for loop) seems to be buggy: if there > are multiple

Re: heap doesn't appear to work as described

2007-04-04 Thread 7stud
On Apr 3, 10:30 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | > |>> My book says that in a heap, a value at position i will be smaller > |>> than the values at positions 2*i and 2*i + 1. > > I am sure your book either uses

Re: heap doesn't appear to work as described

2007-04-04 Thread 7stud
On Apr 4, 7:05 am, [EMAIL PROTECTED] wrote: > My book says that in a heap, a value at position i will be than the > values at positions 2*i and 2*i + 1. > > >> I am sure your book either uses 1-based arrays or a 0-based arrays > >> with the first not used. The need to kee

Re: how to remove multiple occurrences of a string within a list?

2007-04-04 Thread 7stud
On Apr 4, 3:08 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Wed, 04 Apr 2007 00:59:23 -0700, 7stud wrote: > > On Apr 3, 3:53 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > >> > target = "0024" > >> > l = ["0024", &q

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread 7stud
On Apr 4, 10:55 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | For any list x, x.index(item) returns the index of the FIRST > | occurrence of the item in x. Is there a simple way to identify the > | LAST occurrence of an item in a

Re: Indentifying the LAST occurrence of an item in a list

2007-04-04 Thread 7stud
On Apr 4, 11:20 am, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 4, 10:55 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > > > <[EMAIL PROTECTED]> wrote in message > > >news:[EMAIL PROTECTED] > > | For any list x, x.index(item) ret

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 3:36 am, "looping" <[EMAIL PROTECTED]> wrote: > Hi, > for the fun I try operator overloading experiences and I didn't > exactly understand how it works. > > Here is my try:>>> class myint(int): > > def __pow__(self, value): > return self.__add__(value) > > >>> a =

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 12:41 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 4, 3:36 am, "looping" <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > for the fun I try operator overloading experiences and I didn't > > exactly understand how it

Re: operator overloading

2007-04-04 Thread 7stud
On Apr 4, 12:41 pm, "7stud" <[EMAIL PROTECTED]> wrote: > According to Python in a Nutshell(p.102), a name that is a slot can > only be "bound"(i.e. assigned to) inside the class body. Upon closer reading, it actually says that the name "__slots__" has

Re: Newbie Question about sequence multiplication

2007-04-04 Thread 7stud
On Apr 4, 4:48 pm, "John Machin" <[EMAIL PROTECTED]> wrote: >copied straight from "Beginning Python: From Novice to >Professional", > > > Any help would be greatly appreciated > I suggest you get another book. I am currently reading that book, and unless you are an experienced programmer that can

Re: Getting word frequencies from files which are in folder.

2007-04-04 Thread 7stud
On Apr 4, 2:07 pm, [EMAIL PROTECTED] wrote: > My question is how to get word frequencies from this files? > I will be glad to get any help. > --files have a read(), readline(), and readlines() method --strings have a split() method, which splits the string on whitespace(e.g. spaces) --lists have a

shelve error

2007-04-04 Thread 7stud
test1.py: import shelve s = shelve.open("/Users/me/2testing/dir1/aaa.txt") s['x'] = "red" s.close() output:-- $ python test1.py Traceback (most recent call last): File "test1.py", line 3, in ? s = shelve.open("/Users/me/2testing/dir1/aaa.txt") File "/Syste

Re: shelve error

2007-04-04 Thread 7stud
[EMAIL PROTECTED] wrote: > On Apr 5, 12:14 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > test1.py: > > > > import shelve > > > > s = shelve.open("/Users/me/2testing/dir1/aaa.txt") > > s['x'] = "red&

Re: shelve error

2007-04-04 Thread 7stud
On Apr 4, 10:22 pm, [EMAIL PROTECTED] wrote: > how did you generate aaa.txt? Ok, I got it to work by supplying a filename that didn't previously exist. Neither the book I am reading, "Beginning Python: From Novice to Professional" nor the book I am using as a reference, "Python in Nutshell", happ

Re: Can we make a local variable in a function as global variable???

2007-04-05 Thread 7stud
On Apr 5, 3:19 am, "sairam" <[EMAIL PROTECTED]> wrote: > I have some local variables defined in one method and Can I make those > variables as global variables? If so , can any one explain me how can > I do that > > Thanks, > Sairam --- num = None def f1(): global num num = 30 def

Re: shelve error

2007-04-05 Thread 7stud
On Apr 5, 5:20 am, Steve Holden <[EMAIL PROTECTED]> wrote: > 7stud wrote: > > On Apr 4, 10:22 pm, [EMAIL PROTECTED] wrote: > >> how did you generate aaa.txt? > > > Ok, I got it to work by supplying a filename that didn't previously > > exist. Neither th

Re: defining functions

2007-04-05 Thread 7stud
On Apr 5, 12:38 pm, "Andre P.S Duarte" <[EMAIL PROTECTED]> wrote: > How do I define a function, then import it, without having to save it > in lib; like "C:\python25\lib". ? ...or permanently set your PYTHONPATH environment variable to the folders you want python to look in for the modules you imp

Re: elementary tuple question. (sorry)

2007-04-05 Thread 7stud
On Apr 5, 3:08 pm, "Steven W. Orr" <[EMAIL PROTECTED]> wrote: > I have a tuple that I got from struct.unpack. Now I want to pass the data > from the returned tuple to struct.pack > > >>> fmt > > 'l 10l 11i h 4h c 47c 0l'>>>struct.pack(fmt, tup) > > Traceback (most recent call last): >File "", l

Re: "index" method only for mutable sequences??

2007-04-05 Thread 7stud
C.L. wrote: > I was looking for a function or method that would return the index to the > first > matching element in a list. Coming from a C++ STL background, I thought it > might > be called "find". My first stop was the Sequence Types page of the Library > Reference (http://docs.python.org/li

Re: Objects, lists and assigning values

2007-04-06 Thread 7stud
On Apr 6, 1:23 am, Manuel Graune <[EMAIL PROTECTED]> wrote: > Hello Gabriel, hello William, > > thanks to both of you for your answers. I seem to need a > better book about python. > What book are you reading? -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples, index method, Python's design

2007-04-06 Thread 7stud
On Apr 6, 7:56 am, "Paul Boddie" <[EMAIL PROTECTED]> wrote: > The problem with 7stud's quote from GvR is that it's out of date: I would argue that it shows the very guy who invented the language stated publicly there was no good reason for tuples not to have an index method---except for consistenc

os.path.isfile() error

2007-04-07 Thread 7stud
Here's the code: import os, os.path, pprint mydir = "/Users/me/2testing" files = [file for file in os.listdir(mydir)] pprint.pprint(files) print os.path.join(mydir, "helloWorld.py") files = [file for file in os.listdir(mydir) if os.path.isfile(os.path.join(dir, file) ) ] pprint.pp

Re: os.path.isfile() error

2007-04-07 Thread 7stud
On Apr 7, 2:56 am, "7stud" <[EMAIL PROTECTED]> wrote: > Here's the code: > > import os, os.path, pprint > > mydir = "/Users/me/2testing" > > files = [file for file in os.listdir(mydir)] > pprint.pprint(files) > > print os.p

Re: tuples, index method, Python's design

2007-04-07 Thread 7stud
On Apr 6, 1:24 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > Except that that wasn't the only justification. GvR also said: > > """ > For tuples, I suspect such a function would rarely be used; I think > that is most cases where x.index() would be useful, x is generally a > list, whose contents va

Re: tuples, index method, Python's design

2007-04-07 Thread 7stud
On Apr 7, 8:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Sat, 2007-04-07 at 06:45 -0700, [EMAIL PROTECTED] wrote: > > Carsten Haese: > > > The lack of convincing use cases is still a pertinent reason today. Note > > > that the original poster on this thread did not present a use case for >

Re: Objects, lists and assigning values

2007-04-07 Thread 7stud
On Apr 7, 2:52 pm, Manuel Graune <[EMAIL PROTECTED]> wrote: > "7stud" <[EMAIL PROTECTED]> writes: > > > What book are you reading? > > I worked my way through most of the online-docs. A bit to casual > obviously. > See the online tutorial'

python, wxpython and Mac OS X

2007-04-08 Thread 7stud
Hi, I'm using an intel imac which came with python 2.3.5 pre-intstalled on OS 10.4.7. I was able run a hello world wxPython script in Terminal by typing: $pythonw wxPythonTest.py Yesterday, I installed python 2.4.4 which I downloaded from the MacPython website, and it seems to have installed co

Re: python, wxpython and Mac OS X

2007-04-08 Thread 7stud
On Apr 8, 8:46 pm, Robert Kern <[EMAIL PROTECTED]> wrote: > 7stud wrote: > > Why 2.4.4 instead of the official 2.5 binary fromwww.python.org? > > http://www.python.org/download/ > 1) On some download page that listed both python 2.5 and 2.4, it said that python 2.4 h

Re: shelve error

2007-04-08 Thread 7stud
> Discussion subject changed to "Python universal build, OSX 10.3.9 and > undefined symbols when > linking" by David Pratt What gives? How come you can change the title of my thread? On Apr 8, 8:14 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > But if you open an errata for the missing explana

Re: Exec Statement Question

2007-04-08 Thread 7stud
On Apr 8, 11:31 pm, "Gregory Piñero" <[EMAIL PROTECTED]> wrote: > I'm curious why this code isn't working how I expect it to: > > import sys > d=3 > > def func1(a,b,c): > print a,b,c,d > print sys.path > > exec "func1(1,2,3)" in {'func1':func1} > > > returns: > 1 2 3 3 > [ sys.path stu

Re: Is there a simple function to generate a list like ['a', 'b', 'c', ... 'z']?

2007-04-09 Thread 7stud
On Apr 9, 2:29 am, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > Is there a simple function to generate a list like ['a', 'b', 'c', ... > 'z']?   The range() just can generate the numeric list. Not very simple, but how about a list comprehension: import string lst = [char for char in string.let

Re: python, wxpython and Mac OS X

2007-04-09 Thread 7stud
On Apr 9, 8:10 am, Robert Kern <[EMAIL PROTECTED]> wrote: > > Should I remove 2.4.4 and install 2.5 instead? > > No, it's okay. > > -- > Robert Kern Ok, thanks. I'll download wxPython and see if I can get it installed properly. -- http://mail.python.org/mailman/listinfo/python-list

setup() and C extensions

2007-04-09 Thread 7stud
Hi, I can't find any documentation on the setup() function in the distutils.core module; specifically I want to know what the 'name' argument does. In some examples in the python docs, they use the name argument like this: from distutils.core import setup, Extension module1 = Extension('dem

Re: setup() and C extensions

2007-04-09 Thread 7stud
Also: 1) When you create a C array to map python names to the C functions that you defined: static PyMethodDef MyFunctions[] = { {"my_calc", (PyCFunction)my_func, METH_VARARGS, "my very speedy c function"}, {NULL, NULL, 0, NULL} }; Why do you need to cast my_func to PyCFunction? 2) Whe

Re: how to get char ASCII value.

2007-04-10 Thread 7stud
On Apr 10, 12:57 am, [EMAIL PROTECTED] wrote: > for an example: > 'a' value 0x61 > '1' value 0x31. How about: import string for char in string.lowercase: print hex(ord(char) ) -- http://mail.python.org/mailman/listinfo/python-list

__file__

2007-04-10 Thread 7stud
Hi, I'm having trouble understanding what the definition of __file__ is. With this program: -- #data.py: def show(): print __file__ if __name__ == "__main__": show() --- if I run data.py with the prompt pointing to the directory that contains data.py, then __file__ produces a f

Re: Does python have the static function member like C++

2007-04-10 Thread 7stud
On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > I define the class like this: > class AAA: >     counter = 0 >     def __init__(self): >         pass >     def counter_increase(): >         AAA.counter += 1 >         print "couter now :", AAA.counter > > But how could I call the

Re: Does python have the static function member like C++

2007-04-10 Thread 7stud
On Apr 10, 9:08 pm, "人言落日是天涯,望极天涯不见家" <[EMAIL PROTECTED]> wrote: > I define the class like this: > class AAA: >     counter = 0 >     def __init__(self): >         pass >     def counter_increase(): >         AAA.counter += 1 >         print "couter now :", AAA.counter > > But how could I call the

Re: install wxPython

2007-04-10 Thread 7stud
On Apr 9, 2:20 pm, Marco <[EMAIL PROTECTED]> wrote: > Hi, > > I have a problem to install wxPython on my MacBook (Pythonversion 2.5). > If would install the wxPython (python setup.py install), then I got > this error: > > Traceback (most recent call last): > File "/Users/marco/Desktop/flexo1/wxpy

Re: Calling Python from Javascript?

2007-04-11 Thread 7stud
On Apr 11, 1:50 am, Kenneth McDonald <[EMAIL PROTECTED]> wrote: > I know that there's some work out there to let Python make use of > Javascript (Spidermonkey) via (I assume) some sort of bridging C/C++ > code. Anyone know of efforts to allow the reverse? I'd really like to > make use of Python whe

Re: __file__

2007-04-11 Thread 7stud
Hi, Thanks for the response. On Apr 11, 12:49 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > __file__ corresponds to the filename used to locate and load the module, > whatever it is. When the module is found on the current directory > (corresponding to '' in sys.path), you get just t

Re: Hellow World:)

2007-04-11 Thread 7stud
If I were you, I would consider obtaining the book Learning Python. I have the newer edition of Pratical Python, which is called Beginning Python: From Novice to Professional, and I wouldn't recommend it. I think Learning Python would be ideal except that it's a couple of years old, and therefore

Re: pop() clarification

2007-04-11 Thread 7stud
On Apr 11, 10:44 am, "Scott" <[EMAIL PROTECTED]> wrote: > As said before I'm new to programming, and I need in depth explaination to > understand everything the way I want to know it, call it a personality quirk > ;p. > > With pop() you remove the last element of a list and return its value: > > No

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
1) You have this setup: logMonths = {"Jan":"01", "Feb":"02",...} yearTotals = { "2005":{"01":0, "02":0, } "2006": "2007": } Then when you get a value such as "Jan", you look up the "Jan" in the logMonths dictionary to get "01". Then you use "01" and the ye

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
IamIan wrote: > Hello, > > I'm writing a simple FTP log parser that sums file sizes as it runs. I > have a yearTotals dictionary with year keys and the monthTotals > dictionary as its values. The monthTotals dictionary has month keys > and file size values. The script works except the results are

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 2:57 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > IamIan a écrit : > > yearTotals = dict([(year, dict.fromkeys(months, 0)) for year in years]) > > HTH List comprehensions without a list? What? Where? How? -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 7:01 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 11, 2:57 pm, Bruno Desthuilliers > > <[EMAIL PROTECTED]> wrote: > > IamIan a écrit : > > > yearTotals = dict([(year, dict.fromkeys(months, 0)) for year in years]) > > > HTH &g

Re: Nested dictionaries trouble

2007-04-11 Thread 7stud
On Apr 11, 7:28 pm, "7stud" <[EMAIL PROTECTED]> wrote: > On Apr 11, 7:01 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > On Apr 11, 2:57 pm, Bruno Desthuilliers > > > <[EMAIL PROTECTED]> wrote: > > > IamIan a écrit : > >

Re: python regular expression help

2007-04-11 Thread 7stud
On Apr 11, 7:41 pm, liupeng <[EMAIL PROTECTED]> wrote: > pattern = re.compile(r'\w+\s*=\s*[0-9]*.[0-9]*\s*') > lists = pattern.findall(s) > print lists > ['a=4 ', 'b=3.4 ', 'c=4.5'] > > On Wed, Apr 11, 2007 at 06:10:07PM -0700, Qilong Ren wrote: > > Hi, everyone, > > > I am extracting some informat

Re: python regular expression help

2007-04-11 Thread 7stud
On Apr 11, 10:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Wed, 11 Apr 2007 23:14:01 -0300, Qilong Ren <[EMAIL PROTECTED]> > escribió: > > > Thanks for reply. That actually is not what I want. Strings I am dealing > > with may look like this: > > s = 'a = 4.5 b = 'h' 'd' c =

Re: __file__

2007-04-11 Thread 7stud
On Apr 11, 6:55 am, "John Machin" <[EMAIL PROTECTED]> wrote: > On Apr 11, 8:03 pm, "7stud" <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > Thanks for the response. > > > On Apr 11, 12:49 am, "Gabriel Genellina" <[

Re: python regular expression help

2007-04-12 Thread 7stud
On Apr 11, 11:15 pm, [EMAIL PROTECTED] wrote: > On Apr 11, 9:50 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> > lhs = re.compile(r'\s*(\b\w+\s*=)') > for s in [ "a = 4 b =3.4 5.4 c = 4.5", > "a = 4.5 b = 'h' 'd' c = 4.5 3.5"]: > tokens = lhs.split(s) > results = [tokens[_] + tokens[_+1] for

wxPython, mac, wx.HSCROLL not working

2007-04-12 Thread 7stud
Hi, I'm trying to allow for a horizontal scrollbar on a textarea, but the scrollbar won't appear when I enter a long string of text(by leaning on one character on my keyboard): import wx app = wx.App() win = wx.Frame(None, title="Text Editor", size=(150, 150) ) tb = wx.TextCtrl(win, pos

reading from sys.stdin

2007-04-12 Thread 7stud
I can't break out of the for loop in this example: -- import sys lst = [] for line in sys.stdin: lst.append(line) break print lst --- But, I can break out of the for loop when I do this: - import sys lst = [] for line in open("aaa.txt"): lst.append(line) br

Re: Newbie help with array handling

2007-04-12 Thread 7stud
loial wrote: > I am new to python and am converting an awk script to python > > I need to store some data in an array/table of some form > > keyvalue1, value1, value2, value3 > keyvalue2, value1,value2, value3 > keyvalue3, value1,value2,value3 > etc > > I will later need to sort in keyvalue order

<    1   2   3   4   5   6   >