be running the same version of Python on each. At least both versions
should be on
the same side for the Python 2.x/3.x version change.
Gary Herron
The same script works fine from linux.
I have also notices some other slight differences: this is my original
script that runs and completes
I have the DOS box with the message
Localhost CGI server started
But when i try this
Back in the www directory,
1.. Open the web link http://localhost:8080/adder.html (preferably in a new
window, separate from this this tutorial).
2.. You should see an adder form in your browser
provide many more.
My personal view is that 0-based loops/indices is *far* more natural,
and the 1-based loops/indices are a *huge* source of off-by-one errors.
But I'm sure others will argue over that point.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
you to either create the needed
buffer? Or perhaps you could by-pass the need for a buffer, and just
use the byte string.
Gary Herron
Help appreciated,
Simon Hibbs
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
at the
printoutfile, ...
form in Python 2.5. In Python 3.X, the
print(...)
function will get you the functionality (I think) you want.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
to reconstruct an equivalent object. This new version of the
original foo may or may not be adequate for your use.
Gary Herron
Thanks in advance,
Julien
--
http://mail.python.org/mailman/listinfo/python-list
(inst) for inst in a]
would be much more readable, and you could document
*why* you are doing this in the def of QuoteIfString
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
starts with.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
reason
to use sys.exit() given exit()'s availability?
If there is an advantage to sys.exit() over exit(), then does sys.exit() have
any advantage over raise SystemExit, 'some error message' in cases where a
module has no other reason to import sys?
--
Gary Robinson
CTO
Emergent Music, LLC
this helps,
Gary Herro
--
http://mail.python.org/mailman/listinfo/python-list
to write a DLL in C/C++ that calls the function first?
Thanks!
Siegfried
See the ctypes module for a method of calling any C callable function in
and DLL.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
srinivasan srinivas wrote:
I want to do something like below:
1. first, second, third, *rest = foo
Python 3.0 has exactly this feature. No current Python 2.x version has it.
Gary Herron
2. for (a,b,c,*rest) in list_of_lists:
Please suggest.
Thanks,
Srini
Bring your gang
answer as to what happens in
python?
Thanks
No code is duplicated. 50 objects are created. Each object has its own
copy of the data attributes, and a reference to the (one and only) class
object where the method attributes are located.
That's a short answer. Perhaps too short?
Gary Herron
to register and start a service, and how to stop and remove it
later. Google finds lots of information on this -- perhaps I'll post my
result when I've pulled it all together.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
whatever
i -= 1
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
process wrote:
In erlang you can cons like this: [1|2]. i tried this in python and it
didnt raise an error but i dont know what the result do
In Python | is the logical bitwise-OR operator. Look at the binary
representation of the numbers to understand it.
Gary Herron
[1|2
A. Joseph wrote:
I need an ebook or tutorial that teach matrix programming.
Perhaps you should start here:
http://www.catb.org/~esr/faqs/smart-questions.html#intro
Gary Herron
--
http://mail.python.org/mailman
* it is you want!
Gary Herron
On 9/23/08, *Gary Herron* [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
A. Joseph wrote:
I need an ebook or tutorial that teach matrix programming.
Perhaps you should start here:
http://www.catb.org/~esr/faqs/smart-questions.html#intro
Googling for them,
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
// Or some such
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
Gary Herron wrote:
process wrote:
Let's say I have a class X which has 10 methods.
I want class Y to inherit 5 of them.
Can I do that? Can I do something along the lines of super(Y, exclude
method 3 4 7 9 10) ?
--
http://mail.python.org/mailman/listinfo/python-list
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
worth a test.
If you run timing test, let us know the results.
Gary Herron
I implemented this the following way:
def get_highest_bit_num(r):
i = -1
while r 0:
r = 1
i = i + 1
return i
This works, but it is a very unsatisfying solution, because it is so
this:
import re
re.sub('[0-9]', '',
ttccatttctggacatgacgtctgt6901ggtttaagctttgtgaaagaatgtgctttgattcg)
'ttccatttctggacatgacgtctgtggtttaagctttgtgaaagaatgtgctttgattcg'
Gary Herron
--
Beema Shafreen
--
http
unexpected, and
definitely undesirable.
I don't believe it -- send your *actual* code, and we'll all have a look.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org
) if not i or str[i-1] != c]
new_str = ''.join(r)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
like a slight abuse of my time to see this
problem on the newsgroup again.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
A_H wrote:
Help!
I've scraped a PDF file for text and all the minus signs come back as
u'\xad'.
Is there any easy way I can change them all to plain old ASCII '-' ???
str.replace complained about a missing codec.
Hints?
Encoding it into a 'latin1' encoded string seems to work:
Gary Herron wrote:
A_H wrote:
Help!
I've scraped a PDF file for text and all the minus signs come back as
u'\xad'.
Is there any easy way I can change them all to plain old ASCII '-' ???
str.replace complained about a missing codec.
Hints?
Encoding it into a 'latin1' encoded string
Use the builtin vars to get a dictionary of names and associated objects.
import sys
for name,ob in vars(sys).items():
print name,type(ob)
Gary Herron
setrecursionlimit type 'builtin_function_or_method'
getfilesystemencoding type 'builtin_function_or_method'
path_importer_cache type
getattr (stands for get attribute) to do this.
fn = getattr(x, v) # Get the method named by v
fn(...)# Call it
Or in one line:
getattr(x,v)(...)
Gary Herron
PHP code for this would be:
class X {
function a() {
}
}
$x = new X();
$v = 'a';
$x-$v();
I need a solution
(...) # is numpy's all
__builtins__.all(...) # Is the original all
Don't import *, but rather import only those things you need.
from numpy import array, dot, float32, int32, ...
and if you need numpy's all
from numpy import all as numpy_all
Gary Herron
Marc
--
http
Max M wrote:
Sverker Nilsson skrev:
I was talking about Guido van Rossum
The one who decides, so far when people agree
I have been using Python since the nineties. I cannot remember when I
have had to rewrite old code because of changes in the language.
At the same time I have been
Zerge wrote:
Hi,
Is there a theoretical limit to the number of items that can be
appended to a list?
thanks
--
http://mail.python.org/mailman/listinfo/python-list
No, only practical limits of memory, time and such.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
mydict[(0,person,clrTime)] = 22:09:30
Would that work for you?
Gary Herron
Can someone help me with right declaration usages. Your help will be
highly appreciated.
Regards
Alok
--
http://mail.python.org/mailman
than getting at them by name.
Cheers,
Dave
For this object (and many others), you can get at the attributes with
the vars(...) builtin.
It returns a dictionary of attribute names and values.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman
:
...
Or try this shortcut (for the exact same effect):
RUNNING, PAUSED, GAMEOVER = range(3)
Gary Herron
Later, each time I want to assign a variable some state, or check for
the state, I must do:
if state == self.GameState.running:
This is somewhat long and tiresome to type
Dark Wind wrote:
Hi,
Is there any command in Python which gives the code for a function
like just typing the name of a function (say svd) in R returns its code.
Thank you
Nope.
--
), (2, 5, 10), (2, 5, 12), (4, 3, 10), (4, 3, 12),
(4, 5, 10), (4, 5, 12)]
Gary Herron
Can anyone give me some advice on how to achieve this ? I got a little
idea, but still need to keep working til i get it. Thanks in advance,
Victor
--
http://mail.python.org/mailman/listinfo/python-list
lose the property that the function works on any object.
No you don't. If you were happy with printing the str(...) of a single
objects, why not just printout the (concatenation) of the str(...) of
each of many objects?
stderr.write( .join([str(b) for b in objs])+\n)
Gary Herron
into that directory
python setup.py build
python setup.py install
Then your import should work fine.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
are not clearcut, then try some real profiling.
Gary Herron
Thanx in advance for the time reading this.
Pantelis
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
to just use the iterator.
for line in file:
...
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
of directory path...
Gary Herron
Any help and/or advice would be appreciated.
- Jeff
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
.
Much simpler this way. This produces the number of whole start and the
number of half stars:
v = ... calculate the average ...
whole = int(v+0.25)
half = int(2*(v+0.25-whole))
Gary Herron
My Solution (in Python):
# round to one decimal place and
# separate into whole and fractional parts
. The underscores
have no special significance here, but they do make the code hard to read.
The first part of the statement directs the print to send the output to
a file, named fd, which was presumably opened earlier ... but I don't
think that was part of your question.
Gary Herron
Thanks!
--
http
to enable it?
Thanks!
Try again. I think you'll find it's still there -- although you have to
execute a something that returns a value before it's set for the first time.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
all the imported modules, but I suspect you'll find that it's much
easier to let py2app and py2exe determine what's imported than it is to
go through sys.modules yourself.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
Karlo Lozovina wrote:
This is what I'm trying to do (create a list using list comprehesion, then
insert new element at the beginning of that list):
result = [someFunction(i) for i in some_list].insert(0, 'something')
But instead of expected results, I get None as `result`. If instead of
of information
about a method (even including the file name and line number where it
was defined). Poke around and perhaps you can find exactly what you are
looking for.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
Rainy wrote:
I have a stylistic question. In most languages words in var. name are
separated by underscores or cap letters, resulting in var names like
var_name, VarName and varName. I don't like that very much because all
3 ways of naming look bad and/or hard to type. From what I understand,
AttributeError:
pass
or:
try:
del obj.foo
except AttributeError:
pass
or:
if hasattr(obj, 'foo')
delattr(obj, 'foo')
For backwards compatibility, allow_missing would default to False.
Gary
--
http://mail.python.org/mailman/listinfo/python-list
) or so.
Happy google-ing and good luck.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
function that does what you
want.
import re
r =',|;' # or this also works: '[,;]'
s = a,b;c
re.split(r,s)
['a', 'b', 'c']
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
of this is a stupid question)
Not stupid. It will all start making sense soon.
Gary Herron
Dan
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
?
No.
Conclusion: Don't use reload (ever). A dozen years of Python
programming, and I've never used it even once. If there is a
good use case for reload, you are probably years from being there.
Gary, thanks very much for your help.I suspected it was something
like this. I still can quite
.
self.SomeField = params[mykey] if params.has_key(mykey) else None
Gary Herron
Obviously I know this is not actual Python syntax, but what would be
the equivalent? I'm trying to avoid this, basically:
if params.has_key(mykey):
self.SomeField = params[mykey]
else
is
a trade off (like any caching scheme) of cache-space versus efficiency
gains. The value has changed at least once in recent versions of Python.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Serve Lau wrote:
What is the expected result of -1/2 in python?
--
http://mail.python.org/mailman/listinfo/python-list
From the manual:
The result is always rounded towards minus infinity: 1/2 is 0, (-1)/2 is
-1, 1/(-2) is -1, and (-1)/(-2) is 0.
Gary Herron
--
http://mail.python.org
Christian Heimes wrote:
Serve Lau wrote:
What is the expected result of -1/2 in python?
0
No. That's not right. (It would be in C/C++ and many other languages.)
See my other response for the correct answer.
Gary Herron
Christian
--
http://mail.python.org/mailman
python-list. Like this:
class ParentClass(object):
... def __init__(self, keyword1, keyword2):
... print 'ParentClass.__init__ called with', keyword1, keyword2
...
class ChildClass(ParentClass):
... pass
...
child = ChildClass(123,456)
ParentClass.__init__ called with 123 456
Gary
limit wrong? I guess so! But I'm pretty sure I saw it max out at 2GB on linux...
Anybody have an explanation, or is it just that my understanding of a 2GB limit
was wrong? Or was it perhaps right for earlier versions, or on linux...??
Thanks for any thoughts,
Gary
--
Gary Robinson
CTO
Emergent
and the standard module named imp.
Gary Herron
*
*
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
thing: Find out what value that index has, then if it's necessary
to ask your question again, include that information and we'll have
something to go on in forming an answer.
Gary Herron
I have this error message:
IndexError: each subindex must be either a slice, an integer,
Ellipsis
Gary Herron
The only problem is if I leave a comment only in the except block, I
get an error back saying that the except block is not properly
formatted, since it has no content other than a comment.
So if anyone could suggest some code to put there as a placeholder
that would be wonderful
: *never* use is.
(A longer answer can find some uses cases for is, but stick with the
short answer for now.)
Gary Herron
Python 2.5.2
'string' is 'string' #simple assignment works
True
s = 'string'
s is 'string'
True
def make_string(): return 'test
/mailman/listinfo/python-list
Pyglet is my favorite: http://www.pyglet.org/
Twisted might be fine for the online multiplayer parts, but really if
you want a 2D/3D real-time game, start with a game framework.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
chamalulu wrote:
On Jul 1, 11:24 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote:
chamalulu schrieb:
Hello.
I think I'm aware of how attribute access is resolved in python. When
referencing a class instance attribute which is not defined in the
scope of the instance, Python looks for a
chamalulu wrote:
On Jul 2, 1:17 am, Gary Herron [EMAIL PROTECTED] wrote:
No need. Also, you can define a class attribute (C++ might call it a
static attribute) and access it transparently through an instance.
class C:
aClassAttribute = 123
def __init__(self, ...):
...
c = C
for it.
Good luck.
Gary Duzan
Motorola HNM
--
http://mail.python.org/mailman/listinfo/python-list
differences (mutability, sorting and other
methods, types of individual elements), I'd say there are more
differences than similarities, even though, as sequences, they both
support a small subset of similar operations.
Gary Herron
David C. Ullrich wrote:
Luckily I tried it before saying
looking carefully
throughout the code.
Gary Herron
Thank you,
Robert
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
assigned into it:
codecs = ...something overwriting the module object ...
Gary Herron
I wonder if I need to do something before using the codecs library
from within the cgi module?!
Thank you very much for your help,
Nora
exactly one day ago:
from datetime import *
datetime.today()
datetime.datetime(2008, 7, 10, 13, 38, 48, 279539)
datetime.today()-timedelta(1)
datetime.datetime(2008, 7, 9, 13, 38, 50, 939580)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
RV wrote:
On Thu, 10 Jul 2008 13:39:29 -0700, Gary Herron
[EMAIL PROTECTED] wrote:
The datetime module has what you need.
It has methods (with examples) on building a datetime object from a
string, and it has a object named timedelta, and the ability to subtract
a timedelta from a time
-in-python
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
of module ABC has not
progressed to the point that abc is defined.
The solution: Just
import ABC
and later reference ABC.abc
That being said, it is still a good design practice to structure your
modules hierarchically rather than a circularly.
Gary Herron
--
http://mail.python.org/mailman
might be your definition
of) a word, and in particular will match abc in :abc:. Regular
expressions have lots of other special \-sequences that might be worth
your while to read about: http://docs.python.org/lib/re-syntax.html
Gary Herron
--
http://mail.python.org/mailman/listinfo/python
shells will provide similar functionality using a variety
of similar syntaxes: , , , and |, and so on.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
the assignment.
If weights_array is a function, then
weights_array(randomizing_counter)
is the proper way to call the function, but the value returned cannot be
the object of an assignment.
Gary Herron
# Assign the first randomized value to our first word to be weighted
jolly wrote:
Hey guys,
I'm rather new to python and i'm have trouble(as usual)
I want to know if it is possible to change where 'import' looks
this will save me clogging up my python directory
Thanks
Easily done. The value of sys.path is a list of directories that import
looks
packages that represent numbers (integer and
floating point) with larger collections of bit.
Try looking at GMP at for one such package: http://gmplib.org/
Good luck,
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
Instantly Turn your Computer into a Super TV
• Watch all your favorite shows on your Computer TV!
• Channels you can’t get any other place in the U.S.A!
• Watch from anywhere in the world!
• Save 1000's of $$$ over many years on cable and satellite bills
• INSTANT DOWNLOAD
• And much, much more!
.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
it's value.
2. You could also dispense with use of global values -- various OOP
techniques could help there.
Gary Herron
Thanks!
Cheers,
Valia
--
http://mail.python.org/mailman/listinfo/python-list
The $ is not used in any Python syntax. Neither in variable names nor
any syntactical construct.
Of course, like any character, it can be used in strings. (And some
packages, like re, will make special use of a $ in a string.)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python
f.close()
Gary Duzan
Motorola CHS
--
http://mail.python.org/mailman/listinfo/python-list
(at least some) wireless cards are involved.
You may be better off using a package that knows all this and handles it
properly. Modules asyncore and asynchat are one possibility.
Gary Herron
the sample code is as follows
#server
import socket
s = socket.socket(socket.AF_INET
')
looks up the value associated with the key if it exists, otherwise it
returns the provided default value.
You may also want to checkout the dictionary method setdefault which has
the functionality of get PLUS if the key is not found, it adds the
key,value pair to the dictionary.
Gary Herron
/ever/...,
Gary Herron
import os, sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
# hack for Windows: os.environ not propogated
[deleted, I'm running linux]
. . .
os.chdir(webdir) # run in html
root dir
]).
Gary Duzan
Motorola HNM
On Aug 14, 8:03 am, Laurent Pointal [EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] a écrit :
Try this:
com.JPypeTest.main(arg)
Ian
Thanks for your suggestion, but it doesn't work (produces an error
and complexity into a byte string which can be
sent across a socket. On the receiving end of the socket, the byte
string can be turned back into an equivalent Python object.
Gary Herron
Cheers,
Marek
--
http://mail.python.org/mailman/listinfo/python-list
Oğuz Yarımtepe wrote:
On Thursday 16 August 2007 11:20:38 Gary Herron wrote:
If you really want to send any Python object through a socket, look up
the Pickle and cPickle modules. These will marshal (as it's called) any
Python object of any type and complexity into a byte string which can
secondsPerDay = 24*60*60
today = time.time()
yesterday = today - secondsPerDay
print time.strftime(%d%m%Y,time.localtime(today))
16082007
print time.strftime(%d%m%Y,time.localtime(yesterday))
15082007
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
CAN extract the key,value pairs from a dictionary into a list,
and sort that list (by any criteria you want).
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
finally came up with:
exec self.%s = '%s' % (item, plist[item])
Yuck! Not at all necessary. Use setattr instead:
setattr(self, item, plist[item])
That's much cleaner then an exec or eval. You may also find getattr and
hasattr useful.
Gary Herron
A more simple example for setting
the window is open, PyOpenGL (versions 2xx or 3xx) work
perfectly on the window.
See http://www.fltk.org/
Gary Herron
However, it doesn't (easily) work with common GUIs like GTK and Wx.
If you want to use use OpenGL in a GUI app, then you'll want to find
an OpenGL canvas widget for that GUI
, to tell
us *what* it is you are releasing. Just a sentence or two and a URL
would be only common courtesy.
Thanks,
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
a list as a function. Example:
someList = [1,2,3]
someList(99)
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: 'list' object is not callable
Gary Herron
please help
Ps: rather than doing in your head making a test prgram to run exactly
that might
,j
...
0 10
1 11
2 12
3 13
4 14
5 15
6 16
7 17
8 18
9 19
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
201 - 300 of 1049 matches
Mail list logo