Hello,
In my script library, one directory is named rendering. When I try
to import a module from this directory, I always get this error:
#ImportError: dynamic module does not define init function (initrendering)
However, there is an __init__.py file in there, and also the pyc
version. All
That would be the compileall utility:
http://www.python.org/doc/2.4.1/lib/module-compileall.html
Cheers
Bernard
On 7/1/05, Johan Geldenhuys [EMAIL PROTECTED] wrote:
Hi all,
I have python .py files that I want to compile into .pyc files.
Is there a easy way of doing this?
Thanks,
Hello,
Possibly I am missing something, but how do you use the repr() function?
I type this ultra-simple function:
def myFunc(): print 'hello'
Then run
repr( myFunc )
Wich returns
'function myFunc at 0x009C6630'
Okay then I run
s = repr( myFunc() )
print s
Wich returns
'None'
Thanks
Ok thanks a lot.
The real question is, then, is there a way I can print the code of a
function as a string? Something like
'def myFunction: print hello'
Thanks
Bernard
On 6/7/05, Max Noel [EMAIL PROTECTED] wrote:
On Jun 7, 2005, at 20:42, Bernard Lebel wrote:
repr( myFunc
Well, to make a long story short, this is because I use Python through
another software, Softimage|XSI, and by design a string is required to
pass logic to on-the-fly GUIs. Since XSI implements 3 other languages
(ActivePerl, VBScript and JScript), I suppose this was designed that way
with
Indeed, dictionaries don't have a .key attribute.
Instead, use:
# Get list of values for 'key1'
aList = dol[ 'key1' ]
This would return the list of values you have assigned to 'key1' in
the dictionary. Once you got that list, you can look in the list to
find out the index of 'lil1' and return
Well, that was a nice explanation. Thanks once again Kent!
Bernard
On 5/16/05, Kent Johnson [EMAIL PROTECTED] wrote:
Bernard Lebel wrote:
Hi Kent,
So if I undestand you right, mapping a function with map() when it is
a built-in function will/may be faster than a for loop, but if it's
That is very interesting John. Thanks!
Bernard
On 5/19/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Quoting Bernard Lebel [EMAIL PROTECTED]:
Well, that was a nice explanation. Thanks once again Kent!
There is a nice (not too technical) essay on the running speeds of different
Hi Joseph,
To answer your last question first, you should use the
os.path.exsits() method to see if the path is valid:
http://www.python.org/doc/2.4.1/lib/module-os.path.html
As for finding a word in a text, I would suggest to write a basic text
parser that would work on small files.
def
( raw_input( 'what word to searh:' ) )
# Call function
parseText()
# Check if list has at least one element
if len( aWords ) 1: print 'Word not found in file'
else: print str( len( aWords ) ) + ' instances of our word found in file'
Sorry again
Bernard
On 5/18/05, Bernard Lebel [EMAIL PROTECTED
Hi William,
First, check out the os and os.path modules. It has exactly what you
need to handle files and directories.
http://www.python.org/doc/2.4.1/lib/module-os.html
More specifically:
http://www.python.org/doc/2.4.1/lib/os-file-dir.html
http://www.python.org/doc/2.4.1/lib/module-os.path.html
Thanks Alan, that clears things up quite well.
Bernard
On 5/14/05, Alan Gauld [EMAIL PROTECTED] wrote:
So if I undestand you right, mapping a function with map()
when it is a built-in function will/may be faster than a for
loop, but if it's a custom function (ie. a def one), it will
All right, thank you.
Bernard
On 5/12/05, Bob Gailer [EMAIL PROTECTED] wrote:
At 02:17 PM 5/12/2005, Bernard Lebel wrote:
Just a generic question: why one would use apply()?
In Learning Python, on page 357, there is an example of generating an
instance using apply():
class
The authors even go as far as saysing, on page 228 (first paragraph)
that map() used that way has a performance benefit and is faster than
a for loop.
Cheers
Bernard
On 5/13/05, Alan Gauld [EMAIL PROTECTED] wrote:
How bizarre. I'm astonished that Lutz/Ascher even show that as a means
of
Hi Kent,
So if I undestand you right, mapping a function with map() when it is
a built-in function will/may be faster than a for loop, but if it's a
custom function (ie. a def one), it will most likely be slower?
Thanks
Bernard
On 5/13/05, Kent Johnson [EMAIL PROTECTED] wrote:
Bernard Lebel
Just a generic question: why one would use apply()?
In Learning Python, on page 357, there is an example of generating an
instance using apply():
class A:
def __init__( self, number ):
self.number = number
a = apply( A, 3 )
What is the benefit of doing this over simply
Hello,
Let say I have several class instances in a list, and these class
instances have an attribute named value, whose value is an integer.
I would like to know if it is possible to loop over the list of
instances to change their value attribute, using a map( (
lambda:...), ... ) type of loop.
to
define a function.
Cheers
On 5/11/05, Danny Yoo [EMAIL PROTECTED] wrote:
On Wed, 11 May 2005, Bernard Lebel wrote:
Let say I have several class instances in a list, and these class
instances have an attribute named value, whose value is an integer.
I would like to know
Hello,
I just started using list comprehensions (loving them!)
I know you can add an if statement, but can you put in there an else?
I could not find an example of this.
Thanks
Bernard
___
Tutor maillist - Tutor@python.org
Hello,
I have an object, and this object has attributes. These attributes are
objects in their own right, and each attribute also have its own attributes.
So I loop over the top object, and for each attribute encountered, I
want to put in a list two of the attributes of this attribute. Hope it
Hi,
The one thing I would try, if I understand what you're after
correctly, would be to run a exec command with the module name.
modulename = 'myModule'
exec 'import ' + modulename
Then you can access the module names as any imported module.
Cheers
Bernard
On 4/19/05, Tim Johnson [EMAIL
Thanks a lot, now it's clear.
Bernard
On Apr 8, 2005 3:48 PM, Andrei [EMAIL PROTECTED] wrote:
Bernard Lebel wrote on Fri, 8 Apr 2005 15:05:13 -0400:
I'm experimenting with basic inheritance concepts, and something that
I would assume to work returns an error.
class A:
... def
Hello,
I'm experimenting with basic inheritance concepts, and something that
I would assume to work returns an error.
class A:
... def __init__( self ):
... self.a = 13
...
class B( A ): # create sub-class of class A
... def __init__( self ):
... self.b = 14
As far as I'm aware, this is very normal. The file is being used by an
application, so there is a lock on it.
Cheers
Bernard
On Apr 4, 2005 7:34 PM, Shidai Liu [EMAIL PROTECTED] wrote:
I found out in the following situation, it fails to work.
Say, 'somefile.csv' is opened by EXCEL,
test!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hoffmann wrote:
Hi All,
I am starting to studying Python. I have some previous
experience with C (beginner level). Could, anyone,
please, suggest a good Python book? I have both
Learning Python by Lutz Ascher, and Python How to
Program by Deitel and others. Are those good books?
Thanks.
Hoffmann
Well, thanks everyone who answered, much clearer now.
Bernard
Max Noel wrote:
In a slightly more generic fashion (everybody started dropping
examples), the goal of an integer (euclidian) division (say, a / b) is
to express an integer as such:
a = b * quotient + remainder
Where all the
Hello,
I have already messed a little with simple thread programming, wich took
this form:
from threading import Thread
def mainFunction():
pass
Thread( target=mainFunction ).start()
Now, I have a list of jobs, each job being a windows bat file that
launches an executable and performs a
expecting to get.
On Tue, 15 Feb 2005 20:58:15 -0500, Bernard Lebel
[EMAIL PROTECTED] wrote:
Hello,
I have already messed a little with simple thread programming, wich took
this form:
from threading import Thread
def mainFunction():
pass
Thread( target=mainFunction ).start()
Now, I have a list
The os module is the answer. Use chdir() to make the target executable's
directory the current directory, and then os.system( 'command' ) to run
the actual command.
Cheers
Bernard
Lobster wrote:
- I am trying to call up an external program
with something like a Shell command - can not find a
Thanks everyone who answered, it's sorted now :-D
Bernard
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hello,
An easy one to start the year.
Trying to write my first class, already running into problems after 3
lines! :-(
So have this little class:
class rt:
def walk(self):
print 'yeah'
So if I write this in the Python shell, instantiate rt and call walk(),
I get the
101 - 132 of 132 matches
Mail list logo