(3)
Then you can refer to the values as
State.OPENED
State.CLOSED
State.ERROR
The extra clarity (and slight wordiness) of the dotted notation seems,
somehow, quite Pythonic to me.
Gary Herron
--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425
James Colannino wrote:
James Colannino wrote:
So then I entered the command print 0600, and saw that the
actual number being output was 384 (why would it output 384?!)
Ok, so further research revealed that 0600 is actually the octal
representation for 384 (which makes sense.) So
faster.
Good luck,
Gary Herron
enas khalil wrote:
hello all
when i run the code :
# -*- coding: cp1256 -*-
from nltk.tagger import *
from nltk.corpus import brown
from nltk.tokenizer import WhitespaceTokenizer
# Tokenize ten texts from the Brown Corpus
explicit about the returned tuple would produce what
you want.
lambda x : (x/60,x%60)
Gary Herron
[EMAIL PROTECTED] ~ $ python
Python 2.4.2 (#1, Nov 18 2005, 19:32:15)
[GCC 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)] on linux2
Type help, copyright, credits or license for more
name,
mac address, ip address and OS on that system.
The platform module can give lots of such info:
http://docs.python.org/lib/module-platform.html
Good Luck,
Gary Herron
Thanks in advance for having given a thought on my questions.
Regards
Yogi
--
http://mail.python.org/mailman/listinfo
...
Several types would qualify as numbers: IntType, FloatType, LongType,
and ComplexType,
and several as strings: StringType and UnicodeType
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
it... What's your complaint, what's your solution, and why
should we listen?
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
it to the wall,
and start walking backwards. You will still be
able to discern the
structure of the code *long* after you can no
longer identify the
curly-braces. (Provided you properly indented you
C++ code -- you *do*
indent you C++ code don't you?)
Gary Herron
Note: No need to follow up with long
. That was an April Fools joke.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
, to take over complete control
of your program. So be carefully.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
= os.getcwd() # Get working directory at startup
(Even if the import of Parameters in some file occurs before the
initialization code has a chance to run.)
Gary Herron
in all of the files (namespaces) where it is needed.
Is there a better way?
Are the two ideas presented above acceptable? If so
this process until the file runs out of
words. (Hint:you can use ramdom.shufflefunction to scramble the letters)
Please can you answer this problem?
This sounds like a school assignment. We make it a habit here to *not*
answer such questions.
Sorry, and good luck with your studies.
Gary Herron
exactly the characters you want to sys.stdout.
Thus: sys.stdout.write('%1d' % i) should do what you want.
Dr Gary Herron
Digipen Institute of Technology
--
http://mail.python.org/mailman/listinfo/python-list
llothar wrote:
Hello,
i'm looking for a simple http proxy in python.
Does anybody know about something like this ?
Here's a list, maintained by Alan Kennedy, of about 20 proxys written
in Python:
http://xhaus.com/alan/python/proxies.html
Enjoy,
Gary Herron
--
http://mail.python.org
, and they support set differences:
from sets import Set
Set([1,2,3,4,5,6]) - Set([2,3,6])
Set([1, 4, 5])
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
. Gary Herron
Digipen Institute of Technology
--
http://mail.python.org/mailman/listinfo/python-list
Russell wrote:
I want my code to be Python 3000 compliant, and hear
that lambda is being eliminated. The problem is that I
want to partially bind an existing function with a value
foo that isn't known until run-time:
someobject.newfunc = lambda x: f(foo, x)
The reason a nested function
and standard operation procedure.The
functions from myFunctions execute in the environment of the module they
were define in, no matter how you import/reference them from another
procedure.
Just try it and you'll be please with the results.
Gary Herron
Is there
a way to make python
string.ljust(PortlinkbeatInv[row[j][0]],14),
^
SyntaxError: invalid syntax
The problem here is that the previous line has unbalanced parentheses.
Fix that, and there should be no problem with this line.
Gary Herron
How should I change to printout row data [1,2,3,4,5] in one row in assigned
LittlePython wrote:
Is this a good place to post python questions from newbie's, or would you
suggest another board?
Thx
This is the correct place. This group has the reputation of being
newbie-friendly.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
to be performed.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
spencer wrote:
Hi,
I'm not sure why I can't concatenate dirname() with basename().
Of course you *can* concatenate them, but you're not getting that far.
The piece
os.path.dirname(os.getcwd)
should be
os.path.dirname(os.getcwd())
Then it will work without raising an exception, but
would
be better spent worrying about how to optimize the other portions of you
code.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
your own dictionary type from the builtin dictionary
type, and map an index operation d[(x,y)] to
d[ImmutableSet(a,b)]. Then all of d[a,b], d[b,a], d[(a,b)] and d[(b,a)]
would index the same element.
See http://docs.python.org/lib/module-sets.html for details of the set
module.
Gary Herron
operator, and find operator.not_ which is a function
and does what you want.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
for the reader.
(Meaning I haven't a clue.)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
,
100 ).
You want getattr and setattr:
setattr(ob, 'blah', 123)
and
getattr(ob, 'blah')
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
.
Basically I'm trying to make a:
if pixel == color:
do_this()
else:
pass
And have it do this as fast as my pc can handle (that is why only
grabbing 1px would be helpful)
Try image.getpixel((x,y)) to retrieve the pixel at (x,y).
Gary Herron
--
http://mail.python.org/mailman/listinfo
answer. However, it you *do* want threads, and you don't
want the main thread to wait for the threads to quit, you can make the
threads daemon threads. See setDaemon method on Thread objects in the
threading module.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
is to keep the
incompatibilities to a minimum, but subject to the larger goal of
producing a cleaner/better language unhindered by the need of absolute
compatibility.
Gary Herron
David Blubaugh
-Original Message-
From: Bill Hart [mailto:[EMAIL PROTECTED]
Sent: Friday, February
for one. The easiest way to do
that is mylist[:]. (This is a shorthand for copying out any sublist of
mylist via the syntax mylist[a:b], with a and b defaulting to whole list.)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
of a pattern matched by an re can be replaces
with a given string. See sub and subn. Perhaps you can make one of
those do whatever it is you are trying to do.
Gary Herron
e.g
re.SomeNewFunc(compilexp, mytable)
myname
mytable = {a : 1}
re.SomeNewFunc(compileexp, mytable
.
Good luck.
Gary Herron
Thanks,
Laszlo
from simpleparse.common import numbers, strings, comments
from simpleparse.parser import Parser
declaration = r'''
expr:= paren_expr/unop_expr/binop_expr/word
paren_expr := (,expr,)
unop_expr := unop,expr
binop_expr
during the calling process as a
dictionary, You can create the dictionary yourself, and slip it into
the calling arguments with a ** notation:
kw = {somestring:32}
x.foo(**kw)
Gary Herron
or
x.MyClass()
y = 'trials'
x.foo(y = 32) # does the wrong thing
Surely there's some way to use
Robert Dailey wrote:
Hi,
Currently I have the following code:
ignored_dirs = (
r.\boost\include
)
You expect this is creating a tuple (or so I see from your in test in
the following code), but in fact the parenthesis do *not* make a tuple.
If you look at ignored_dirs, you'll find
the default a to call
...
And you main program:
from mod import *
def my_a():
...
b(my_a)
Hope that helps
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
(128)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
threads.
Gary Herron
You can have more information here.
http://artfulcode.nfshost.com/files/multi-threading-in-python.html
On Sat, Mar 8, 2008 at 1:11 PM, John Deas [EMAIL PROTECTED] wrote:
Hi,
I would like to write a python script that will download a list of
files (mainly mp3s
be applied to *any* immutable type. For larger ints, such a thing
is not true.
x=1000
y=1000
x is y
False
If either is a surprise, then understand that the is operator should
probably *never* be used with immutable types.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
pass the workspace created in node1, to node 2, etc ?
thanks,
Stef Mientki
RTFM! In particular: http://docs.python.org/lib/built-in-funcs.html#l2h-26
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
of Sets.
--
-=Ravi=-
This sounds like a homework problem, something you should be solving
yourself. If, however, you have any Python questions, then please ask.
We'll be glad to answer them.
--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418
comparison operators work. The meaning is the same as the AND
of each individual test.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
'The while loop is over.'
print 'Done'
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
$ more time.py
import time
*
Right there is the problem. Your program, named time.py, is hiding the
Python supplied module. So that import of time is finding and
re-importing itself. Rename your script to something that won't shadow
a Python library module.
Gary Herron
*print time.time
= subprocess.Popen ([/usr/bin/ls /tmp])
This line fails because of a typo. There needs to be a comma between
the two list elements. Without the comma, this becomes
proc = subprocess.Popen ([/usr/bin/ls/tmp])
which obviously fails.
Gary Herron
Traceback (most recent call last):
File
to look at.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
object obj do:
objMap[str(obj)] = obj
and later with the string in hand, do
obj = objMap[string]
One other word of warning. It is best to not use a variable named
string as Python has a builtin type of that name which would become
inaccessible if you redefine.
Gary Herron
--
http
W. Watson wrote:
In what library would I find gif.save(path), where path is the name and path
of a file, and the method would produce a file in a gif format?
Is there a fits.save(path) somewhere? fits is commonly used in astronomical
work.
You may want to install PIL (the Python Image
the struct module:
http://docs.python.org/lib/module-struct.html
It is meant to solve this kind of problem, and it is quite easy to use.
Gary Herron
Here is my function that takes in a string.
def parseSequence(data, start):
group_num = data[start:start+2]
element_num = data
/it),
then castironpi can be declared to be a truly *intelligent* AI.
AFAICT, there appears no danger of that happening yet.
Gary Herron :-)
--
http://mail.python.org/mailman/listinfo/python-list
Paul Scott wrote:
I have been tasked to come up with an audio recorder desktop (cross
platform if possible - but linux only is OK) that:
1. records a lecture as an MP3 file (pymedia?)
2. Provides a login form for server credentials
3. Uploads via XMLRPC (pyxmlrpclib) to the server as a
Christian Bird wrote:
Is it possible to import multiple modules with the same name from
different locations? I'm using two different pieces of software, both
of which have a module named util.py. I know that I can modify
sys.path to fix which util gets imported when I do:
import util
I'd
please: Why are you surprised?
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
this:
for a in [dictFoo, dictBar, dictFrotz]:
if 'srcdir' in a:
a['srcdir']='/usr/src'
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
idle wrote:
brilliant.
Hardly. Any perceived brilliance is in the design of Python, not our
simple and hopefully effective use of it. :-)
Gary Herron
thanks to both of you.
--
http://mail.python.org/mailman/listinfo/python-list
just make ElementTree
directly importable by either installing it normally or including
.../xml/etree in your PYTHONPATH
Gary Herron
Can anybody help?
THanks
--
http://mail.python.org/mailman/listinfo/python-list
) is wrong since range(2) is [0,1].
You want range(3) which gives [0,1,2].
Gary Herron
but for some reason the list comprehension is not always returning a
list with 2 elements in it (sometimes it will be just 1 element). I've
tried changing to a generator as well as using filter() and all
...
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
]
parameters.theClass.bar()
(Hint: It matters not whether foo is a classmethod, saticmathod or
normal method.)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
, I've used
these various copy methods perhaps a dozen times or less. If you find
you are copying structures often, you are probably not using Python as
effectively as you could.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
python newbie wrote:
Hello,
Just curious; can I post a basic programming question to this mailing
list?
You just did. :-)
(Real answer: Yes. We're pretty newbie friendly here.)
Gary Herron
Thanks in advance.
Pete
all
the hundred variables, and define getter/setter methods for them.
Gary Herron
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type help, copyright, credits or license for more information.
from test_vars import *
dir
. It's an awesome combination.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
in the future.)
Gary Herron
In Python, you usually can use parentheses to split something over
several lines. But you can't use parentheses for an assignment of
several lines. For that, you can use the line continuation character
('\'):
CONSTANT1= \
CONSTANT2= \
CONSTANT3= \
1
= None
Connection = None
Date= None
Pragma = None
...
Gary Herron
Etc etc etc. At the end they'll all be assign to None. Then, when
initialized, __init__() will the the string of headers, parse them,
and use
,
i should only use it, if it does not exist, it may return only empty,
just as in php
i hope you understand my question...
See http://docs.python.org/lib/typesmapping.html for a description of
the get method of dictionaries.
Also look at the
key in dict
syntax on the same page.
Gary
tree structure
representation, it should be a relatively easy job to traverse the tree
to emit the tags and text you want.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
.
If you *are* trying to use the name mangling, then you still don't need
the super.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
differently, but on a specific implementation, the result will not change.
Python 3 will raise an exception on such comparisons.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
, and probably more.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
it:
x = list ...
x.reverse() # reorders, but returns nothing
... now use x ...
You might look at the builtin reversed(list):
http://www.python.org/doc/faq/programming/#how-do-i-iterate-over-a-sequence-in-reverse-order
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
import pi, sqrt
Then use pi, and sqrt.
But other module attributes (like sin, and cos) are not accessible.
Method 3:
from math import *
Then use pi, sqrt, cos, sin, and anything else defined by the module.
(This is sometime frowned upon, but there's no reason to do so here.)
Gary Herron
SL wrote:
How can I compute with the integer values of characters in python?
Like
'a' + 1 equals 'b' etc
--
http://mail.python.org/mailman/listinfo/python-list
You can get an integer value from a character with the ord() function.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python
Good Z wrote:
Hello,
I am having problem in using is. Here is what i am doing.
Short answer: Use == for equality.Don't use is. Ever!
(Especially if you are a newbie.)
Longer answer: In a dozen years of programming Python, the only time I
use is is when testing for something like
,
increment the register
write the value into i.
If a thread is interrupted anywhere within that sequence, and another
thread access i, you have a conflict. (And indeed, hardware interrupts
can occur between any two instructions.)
Gary Herron
--
http://mail.python.org/mailman/listinfo/python
, and we'll
wee if we can help.
Gary Herron
P.S. Having a class attribute AND an instance attribute, both named
value is going to cause trouble.
#
But the last line does not work.
I would like to do a call like:
dummy = Dummy(thisValue = 12)
And that someFunction gets a default
since each thread has it's own set
of register values.
Gary Herron
'as
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Carl Banks wrote:
On May 3, 7:44 pm, Gary Herron [EMAIL PROTECTED] wrote:
Alexander Schmolck wrote:
AlFire [EMAIL PROTECTED] writes:
The threading module already has a function to return the number of Thread
objects currently alive.
I have threads within threads
Alexander Schmolck wrote:
Gary Herron [EMAIL PROTECTED] writes:
But... It's not!
A simple test shows that. I've attached a tiny test program that shows this
extremely clearly. Please run it and watch it fail.
In [7]: run ~/tmp/t.py
final count: 200
should be: 200
(I
Carl Banks wrote:
On May 4, 12:03 pm, Gary Herron [EMAIL PROTECTED] wrote:
Alexander Schmolck wrote:
Gary Herron [EMAIL PROTECTED] writes:
But... It's not!
A simple test shows that. I've attached a tiny test program that shows this
extremely clearly. Please run
with -- tell us what exception you
get.(Or just look at it carefully yourself.) Whatever the problem
is, I don't believe it has anything to do with the spaces.
Gary Herron
open('./my\\ test/test.txt')
Exception
but yet...
import os
os.chdir('./my test')
open('./test')
works just
that (mis)feature because it's so
unclear, and easy to abuse. Most of us in the community support that
point of view and would fight the introduction of such a feature into
Python.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
','1'] for j in b]
...
len(b)
256
b[63]
'0011'
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
.
(Truly, when I found Python, programming became fun again.)
Gary Herron
Tnx,
Raxit
www.mykavita.com
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
be useful. However, this *does*
do what you asked.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
, but you'll get past these trivial problems
soon. Then you'll be more likely to find volunteers who will spend time
to help *if* you spend the time to provide useful information.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
the skill of reading the error messages *very* carefully. Your error says there is no file
named fileName, and if you think about what's on your disk, I'll bet you won't find a
file whose name is fileName.
Gary Herron
where fileName is defined before the line it's used in. It works fine
when I
bc90021 wrote:
...and the exact error message was?
Here is a tip: if you want people to help you, then you have to help
them to help you. Personally, I wouldn't respond to anymore of your
questions because you seem incapable of posting the information that was
requested.
So far, the
or the purpose of the
group. And you've done both and been reprimanded for it. Now, either
go away, or change your attitude and join the group. (You would be
welcome if the attitude changed.) Either way, this group will be it's
usual friendly self.
Gary Herron
Gary Herron wrote
a statement?
Do you even have a list of statements from which we are to work?
Python is a little unusual in what it considers statements.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
. The biggest challenge at the moment is that we have no idea what
you mean by statement, but it is certainly not what Python considers
statements.
Gary Herron
Thanks,
Ohad Frand
-Original Message-
From: Gary Herron [mailto:[EMAIL PROTECTED]
Sent: Monday, May 12, 2008 10:41 PM
/python-list
ReportLabs is a quite extensive open-source project for generating PDF
files.
http://www.reportlab.org/
Enjoy,
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
this leaves unanswered the question of *how* you are supposed
to import that code. I've never used PythonCard so I can't help
further, but I suggest looking at the documentation and examples
supplied. And perhaps waiting for someone with experience with
PythonCard to answer.
Gary Herron
a is trying to access the local variable before the assignment gives it
a value.
You were expecting that the print a pickups it the outer scope a and
the assignment later creates a local scope a, but Python explicitly
refuses to do that.
Gary Herron
--
http://mail.python.org/mailman/listinfo
is the name of the object being created,
self.file is an attribute named file of that object, and the
assignment stores the supplied value there.
Gary Herron
--
http://mail.python.org/mailman/listinfo/python-list
John Henry wrote:
On May 13, 1:49 pm, Gary Herron [EMAIL PROTECTED] wrote:
John Henry wrote:
Hi list,
I can't understand this. The following import statement works fine:
from PythonCard.templates.dialogs import runOptionsDialog
but this one fails
are dedicated to OOP. Years could be
spent learning to apply its concepts. A web search would find a flood
of such information.
Gary Herron
On Wed, May 14, 2008 at 12:25 AM, Gary Herron
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
Hello!
I have trouble understanding something
= pixelComponent[:4] # first 4 bytes
pixelComponent = pixelComponent[4:] # All but first four bytes
buffer = unpack(!f, fourbytes)
There are probably better ways overall, but this directly answers your
question.
Gary Herron
-M
of question. Just try it!
a = 'abcdefghi'
b = a[:4]
print a,b
abcdefghi abcd
Notice that the [:4] index does not change the original array.
Gary Herron
I'm getting weird results now..
-M
Date: Thu, 15 May
John Machin wrote:
On May 16, 2:11 am, Gary Herron [EMAIL PROTECTED] wrote:
Marlin Rowley wrote:
All:
I've got a script that runs really slow because I'm reading from a
stream a byte at a time:
// TERRIBLE
for y in range( height ):
for color in range(4
1 - 100 of 776 matches
Mail list logo