and GIL (global interpreter lock).
HTH,
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
state
simulation across tens of thousands of CPUs"
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
lts of split to variable names.
For example, ky,val = "A-01, 1278".split(",") sets ky to A-01 and val
to 1278. So, you should be able to create an empty dict, and for each
line in your file set the dict entry for that line.
Why don't you start there and show us wha
destin you're assigning
the _results_ of the functions to your dictionary. You probably want to
leave off the parens when declaring the functions. Further, your
functions probably need to return something -- add return statements if
you want the results.
HTH,
Emile
wo and build a dict from the Protein IDs, then
pass file one, break out the Protein ID, and write the concatenated
result out. Something like:
[pyseudocode]
PIDs = {}
for proteinVals in FileTwo:
ID = proteinVals.split()[0]
PIDS[ID]=proteinVals
for eachline in FileOne:
ID = proteinVals.split()[1]
On 10/14/2010 6:50 AM Roelof Wobben said...
Hello,
I found this answer to a problem for me :
print ''.join([zf.getinfo('%s.txt' % p).comment for p in zpp])
So I thought that this would be the same :
for p in zpp:
test = zf.getinfo(p).comment
This isn't transcribed properly
On 10/14/2010 7:48 AM Ara Kooser said...
Morning all,
I took the pseudocode that Emile provided and tried to write a python
program. I may have taken the pseudocode to literally.
So what I wrote was this:
xml = open("final.txt",'r')
gen = open("final_gen.txt",&
know there was such a convention. Serves me right
for being self-taught and self-employed
Pep 8 is the generally accepted style guide.
http://www.python.org/dev/peps/pep-0008/
Although there are few recommendations I don't follow, it's good to
write in the style most everyone else
orks and you're having trouble with the php
invocation and return values, isn't this more of a php issue?
Most of us here do our web serving with python...
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change s
;""The triangular distribution is often used in ill-defined problems
where the underlying distribution is not known, but some knowledge of
the limits and mode exists. Often it is used in simulations."""
HTH,
Emile
___
Tutor maill
On 10/26/2010 12:55 PM Roy Hinkelman said...
I am posting here as well as a PHP list since I am now getting an odd python
error.
The traceback of the python error would help us diagnose the problem but
it's not been included. Can you paste in the actual traceback?
a loop to print
the results.
What have you got so far?
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
quot; from this string of text?
Assuming you've got that string in variable text, and that "SERVICE_NAME
=" is there to be found, I'd do something like
servicename = text.split("SERVICE_NAME =")[1].split(")")[0]
Emile
__
files and other methods
used.
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
;: "))
for In in range(0,NumItems):
print(Entries[In])
confirmed = int(input("Are you happy with this? (y/n): ")
The line above (which would appear to set confirmed to an int) doesn't
have matching parens, which causes an error to be trapped elsewhere.
Emile
_
to 2.7 to provide an easier
upgrade path.
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 11/9/2010 1:29 PM Steven D'Aprano said...
I'm pretty sure I tried it, once, but I might be confabulating.
Cool -- I learned a new word today!
I had to look it up as I thought you were profabulating... :)
Emile
___
Tutor maillist
t and older version is 1)
search in local-global-builtin, and 2) if you assign to it in a scope,
it's local to that scope.
So, blah and foo below are visible in all the functions except any that
specifically assign to blah or foo.
HTH,
Emile
I have a monolothic script with a
hat state. By putting state variables into
member fields, they are accessible to all the methods of the class
without having to be passed as parameters."
So, by his own definition state variables are parameters.
Emile
___
Tutor maillist - Tutor@pyt
priate starting point...
http://docs.activestate.com/activepython/2.4/pywin32/html/com/win32com/HTML/QuickStartServerCom.html
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 11/20/2010 11:03 AM Kirk Bailey said...
OK, I need to create or find a function that will return a list of
DIRECTORIES (only) which are under 'the current directory'. Anyone got
some clue on this? Please advise.
Use os.walk
Emile
Help on function walk in module os:
walk(to
#x27;, 'l', 'o']
>>> list("1234")
['1', '2', '3', '4']
You then compare a string to the numbers 2,4,6,8,10
making the test line:
if a=="2" or a=="4 or a=="6"
year of data at ten minute intervals takes thee seconds on my PC.
Below is how I refactored things.
Emile
-
import datetime, time
from math import sin
from math import cos
from math import degrees
from math import radians
from math import acos
def getLocation():
print("Please s
rns the element in position [1] thereof.
HTH,
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
See
http://sourceforge.net/tracker/index.php?func=detail&aid=2921957&group_id=46487&atid=446302
where it's explained that this bug won't get fixed, but that you can
install from sources.
Emile
On 11/22/2010 1:08 PM ALAN GAULD said...
Forwarding to the list
Please s
On 11/22/2010 3:05 PM John Smith said...
Hi, Emile -
Install from sources? What is that?
see http://pyserial.sourceforge.net/pyserial.html#installation the From
Source section.
I'm not sure what else may be required but it should help get you started.
Emile
I searched for that p
; that were in common use then.
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 11/23/2010 7:30 AM Wangolo Joel said...
I NO LONGER WANT YOUR TUTORIAL
you can unsubscribe at http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://
http://tutoree7.pastebin.com/iragLgDz>.
Did you try:
if n % 2: pass
else: do it here?
or
def x2(n):
return not (n % 2)
Emile
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On 11/23/2010 1:26 PM Richard D. Moores said...
So what's the connection with the tests I've run?
It's an even/odd test.
[ii&1 for ii in range(1,1000,2)]
[ii&1 for ii in range(0,1000,2)]
Emile
___
Tutor maillist - Tutor@py
a.mything()
it's my thing
>>> a.write("this is a test")
>>> a.flush()
>>> a.close()
>>> open(r'c:\testfile','r').read()
'this is a test'
>>>
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
. Further, mail systems (and administrators) are reluctant to
provide spammers an easy way to validate email lists, so where doors may
be opened, you're likely to find them closed anyway.
Emile
___
Tutor maillist - Tutor@python.org
http://
nathan virgil wrote:
Erm, it's still not working...
if selection in choices:
choice = choices[selection]
choice[0](choice[1])
s/bchoice[0]()
main()
("\n\nPress the enter key to exit.")
use a copy form of assignment, eg
List2 = List1[:]
Note however that this form of copy doesn't copy nested structures and
you'll have similar issues in that case. Look into deepcopy.
Emile
List1=[1,2,3]
List2=List1
List2.reverse()
print(List2)
[3, 2, 1]
print(List1)
[3, 2, 1]
Sanhita Mallick wrote:
help
YOU ARE STANDING AT THE END OF A ROAD BEFORE A SMALL BRICK
BUILDING . AROUND YOU IS A FOREST. A SMALL
STREAM FLOWS OUT OF THE BUILDING AND DOWN A GULLY.
Emile
___
Tutor maillist - Tutor@python.org
http
also match items.
but for all DA's and DB's below, is that true?
>>> a = range(52)
>>> import string
>>> DA = dict(zip(a,string.letters))
>>> DB = dict(zip(a,string.letters))
>>> DA == DB
True
>>> DA.items() == DB.items()
True
>&
oduction.html
HTH,
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e "", line 1, in connect
error: (10061, 'Connection refused')
The server again refuses your connection attempt...
What should I do?
I'd start by pinging the server and running nmap on it. Forget imap if
your goal is sending mail. If you don't see po
time the
application is live, although it's also often cited as a gotcha...
and
def get_todo(todo=None):
if todo==None:
todo = {}
...
Both the above allow you to pass in a starting todo dict, so you could
juggle multiple todo dicts...
HTH,
Timo wrote:
# Results file
import shelve
def read_result(person):
results = []
s = shelve.open(RESULTFILE)
try:
results = s[person]
Maybe passing this out prevents s from being garbage collected?
Emile
except KeyError:
#print "No results for this p
Timo wrote:
Emile van Sebille schreef:
Timo wrote:
# Results file
import shelve
def read_result(person):
results = []
s = shelve.open(RESULTFILE)
try:
results = s[person]
Maybe passing this out prevents s from being garbage collected?
What do you mean by passing out
-- it isn't the index
if num!=data[i]:
here you're using i as though it were an index -- maybe use
if num!=i
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
ping!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
e. There're plenty
of examples out there. Maybe you'll have better luck with that.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Wayne Watson wrote:
Perhaps the Pyton organization could produce their mail lists, if they
have any control over them. Maybe that's the source of the
inconsistency?
Has anyone pointed out that posting through gmane eliminates the
inconsistency?
rned -- that'll probably help
clear things up. If it's really a list type, you don't access those
with keys, so self.opt['inifile'] would fail.
test.load_ini()
HTH,
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
d a link that led me to
http://pypi.python.org/pypi/netifaces/0.3
How far does that get you?
HTH,
Emile
I realize I can call ifconfig and then munge the output with awk, but
that seems messy, and before I tried that I though I would ask around.
To give a bit more information, I'm w
re question, when I tried (no 'wb')
assuming you mean 'rb' above
read(size=307200),
why di read
balk at size, syntactically.
read terminates upon first end on line character encountered
HTH,
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
rs.
ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on
Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
c
-- changing the name of the variable used to hold results
shouldn't change the outcome.
I cannot reconcile them. Can someone
explained to me please?
If you expect something different, then you need to write a different
program. What did you want to happen?
Emile
*>>> for let
xt -v
pdftotext version 2.01
Copyright 1996-2002 Glyph & Cog, LLC
[r...@fcfw2 /]# cat /etc/issue
Red Hat Linux release 9 (Shrike)
HTH,
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
johnf wrote:
But if I attempt this
urllib.urlopen( "http://maps.google.com?q='18 Tadlock Place Woodland CA'" )
it always fails.
What do you get? I don't get an error.
Emile
___
Tutor maillist - Tutor@python.org
http:
messy. :)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
def __init__(self):pass
... def __gt__(self,other): return True
...
>>> t = Test()
>>> t>3
True
>>> t>0
True
>>> t>"hello"
True
>>>
And you may even find out why the following work as well...
>>> t<"hello&q
Emilio Casbas wrote:
Hi,
following the example from
http://docs.python.org/3.0/howto/regex.html
...from version 3.0 docs...
If I execute the following code on the python shell (3.1a1):
import re
p = re.compile('ab*')
p
I get the msg:
<_sre.SRE_Pattern object at 0x013A3440>
... is the
Emile van Sebille wrote:
Emilio Casbas wrote:
Hi,
following the example from
http://docs.python.org/3.0/howto/regex.html
...from version 3.0 docs...
If I execute the following code on the python shell (3.1a1):
import re
p = re.compile('ab*')
p
I get the msg:
<_sre.SRE_P
regex
are notoriously hard to master and often obscure.
Seconded. I almost always find it faster and easier to simply write the
python routine I need rather than suffer the pain that results from
getting the regex to actually perform what's nee
on why Python allows such ambiguity here?
Backwards compatibility. The file type was introduced in python 2.2,
before which there was open.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
easy way -- ie, you know where to look and what name to use.
You can discover the name using the inspect module, but it can get
ugly. If you're interested start with...
from inspect import getframeinfo, currentframe
HTH,
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
:
"414243440d0a"
Is there a way in Python to say this is a string of HEX characters like
Perl's pack? Right now I have to take the string and add a \x to every
two values i.e. \x41\x42...
import binascii
binascii.a2b_hex(
g from the file), then look into indexing the resulting list
objects. That should focus your attentions...
Emile
I have a text file that looks like this:
1 the 126 name
2 of 127 very
3 to 128 through
4 and 129 just
5 a 130 form
6 in 131 much
7 is 132 great
etc...
Each has 2 numbers an
pairs[2:4]) ).items() )]
['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine',
'ten', 'eleven', 'twelve']
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
not testing the inputs, you're testing if is_in_dict
_is_ (which of course it is as it's defined and ergo is) -- you need
to pass it your parameters, ie, 'is_in_dict(nombre,dictionary)'
return 1
return 0
def is_in_dict(nom,dict):
also -- it
On 5/13/2009 8:32 AM spir said...
Hello,
I wanted to subclass the type Window of pyGTK for main app windows (for the
obvious reason that they always contain the same init and end code) and run
into an unexpected problem:
=
import pygtk
pygtk.require('2.0')
import gt
e the last entry to the front --
>>> a = [4, 6, 'word', 3, 9]
>>> a.sort()
>>> a.insert(0,a.pop())
>>> a
['word', 3, 4, 6, 9]
>>>
HTH,
Emile
Now I want the word
to be kept in the first location and the numbers to be sort
re info and examples.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
assuming it does the same thing...
xlate = dict( (chr(c),chr(c)) for c in range(256))
xlate.update(control_char_map)
def cleanRepr5(text):
return "".join([ xlate[c] for c in text ])
Emile
I did a test with random strings of typical length f
round.
Like this?
>>> print repr(''.join(chr(ii) for ii in range(20,40)))
'\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\''
>>>
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
def func3():return 3
flist = [func1,func2,func3]
flist[0]()
flist[1]()
flist[2]()
Emile
I do not think Python has a branch indirect construct so I
cannot use anything similar to that methodology. What is the best
approach to take to solve this problem?
Thank you for any assistance, hints
ation.
Emile
It fails saying it could
not build PIL 1.1.6 because visual studio was not found on the system
and but I have already installed the PIL 1.1.6 using binaries available
on the site but review board fails to locate it and every time tries to
download the PIL and fails while buildin
HTH,
Emile
if any of you has ever used Matlab, i mean something really similar to
its workspace, where all the user created variables are stored and
constantly updated
thank you
___
Tutor maillist - Tutor@python.org
http://mail.python.org/ma
On 6/2/2009 11:34 AM Gökhan SEVER said...
In Ipython
Good for IPYTHON -- I wasn't presuming that.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 6/3/2009 12:50 AM spir said...
Le Tue, 02 Jun 2009 10:47:38 -0700,
Emile van Sebille s'exprima ainsi:
On 6/2/2009 8:54 AM roberto said...
hello,
i'd like to ask if there is anything in python which helps to see what
variables have been defined and their type and their dimensio
tter to have:
'Jun 4th 2009'
How would you go about in doing this?
Without reading the docs, you could just strip it out:
formated_date = date_object.strftime(format).replace(" 0"," ")
Emile
Thanks
_
d return to the
python script when I am done; but I do not seem to be able to execute
read stdout; and all examples I have found on the net do not allow me to
interact with the called program.
Any pokes int he right direction?
What O
delimiter=' ', quotechar='|')
for f in files:
do the open here
for row in f:
for cell in row:
if pattern.search(cell):
print ', '.join(row)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
something like (untested):
def within_range(number, median, threshold=5):
return threshold-medianOf course, the ranges you're testing with are all integers, so you may
want to check for that as well.
Emile
Thanks,
___
Tutor maillist - T
t='excel']
[optional keyword args])
for row in csv_reader:
process(row)
HTH,
Emile
On Sat, Jun 6, 2009 at 3:33 PM, Emile van Sebille wrote:
On 6/6/2009 12:19 PM Nick Burgess said...
Thank you. The data is pretty much random thro
range(self, n, n2, threshold=5):
return n == int(n) and (
n < n2+threshold or n > n2 + threshold)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 6/7/2009 8:44 AM Emile van Sebille said...
On 6/7/2009 7:08 AM Gonzalo Garcia-Perate said...
the solution laid somewhere in between:
def within_range(self, n, n2, threshold=5):
if n in range(n2-threshold, n2+threshold+1) and n <
n2+threshold or n > n2 + threshold : retur
here http://vpython.org/contents/download_windows.html
and here http://vpython.org/contents/download_linux.html that they
recommend python 2.5 or 2.6.
I'd suspect that working beyond recommended compatibilities is for the
bleeding edge developers. Most of Python3 still falls in that arena.
Em
On 6/7/2009 10:17 AM Gonzalo Garcia-Perate said...
Emile, Kent thank you both for your reply, after sending my previous
email I realised that it wasn't working as expected in all cases.
this does work:
def within_range_final(self, n, n2, threshold=5):
return n in range(n2-threshol
bers():
for i in range(9549355543, 9549355560):
numbers = i
get(numbers)
call_numbers()
Is there a technical name for a loop like this?
You mean like, automated junk call dialer?
duck-and-cover... :)
Emile
thanks
-david
__
?group_id=10718
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
posts on this mailing list.
What is the nntp address for thsi mailing list?
The news server is nntp://news.gmane.org/
Then subscribe to the lists you're interested in.
Emile
nntp://news.gmane.org/gmane.comp.python.tutor
doesn't
[1, 2, 3])]
... but watch out for composite objects...
>>> show(d,e,a,b,L[0])
[('d', 4), ('e', 5), ('a', 1), ('b', 2), ('L', 1)]
>>> D = dict([('d', 4), ('e', 5), ('a', 1), ('b', 2), ('L', 1)])
>>> D['L']
1
>>> show(d,e,a,b,D['L'])
[('d', 4), ('e', 5), ('a', 1), ('b', 2), ('D', 1)]
I wouldn't rely on this, but it may be of some use and shows a little of
the introspection abilities python provides.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
")
factorial = reduce(mul,range(1,number+1),1)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
d
fewer problems with it. :)
My editor for the past ten years or so has been TextPad on windows with
a variety of syntax plugins. (php,perl,python,pro5,postscript)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
buggy. :)
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 6/16/2009 7:49 AM Kent Johnson said...
How do you measure "better"? Speed, clarity, ...?
... or the first method you think of that gives the right result. Where
else would you find your keys once you've found them?
Emile
___
On 6/15/2009 12:14 PM Michael Powe said...
On Mon, Jun 15, 2009 at 06:34:04AM -0700, Emile van Sebille wrote:
I'm wondering if there might be documented benefits to migrating from my
horse and buggy. :)
Are you in a hurry to get somewhere? ;-)
If 20 LOC/day is average nowadays, how
apabilities and see how short a program will give the same
results.
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On 6/17/2009 3:03 PM Robert Berman said...
Greetings,
I am working on a 'simple' algorithm to solve the problem called PRIME1
explained at http://www.spoj.pl/problems/PRIME1/.
I do have an algorithm based on the Sieve of Eratosthenes and it does
work as I am failing the project not because of
On 6/17/2009 4:48 PM Robert Berman said...
Emile,
Thank your for your comments. I do have a list running from 0-101.
Yes, it is true, I only needed 0 - 10 and yes I will change it.
However, if you use primearray
you haven't posted the primearray code...
However, for the
ildSieve(20)
[0, 0, 2, 3, 0, 5, 0, 7, 0, 0, 0, 11, 0, 13, 0, 0, 0, 17, 0, 19, 0]
So I still don't know what primearray is/does.
Emile
The code is as follows:
def BuildSieve(itemsin):
TheSieve=list()
TheSieve = range(0,itemsin+1)
TheSieve[1]=0
for i in range(2,itemsin+1):
7
... and when it isn't...
>>> Timer("'E' in {'D':123}.keys()").timeit()
0.99194670371434768
>>> Timer("'E' in {'D':123}").timeit()
0.34795386410769424
>>>
Emile
accessing a key that does not exist
w
://www.mobilenin.com/mobilepythonbook/examples/057-btchat.html
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
statements through the code to
track where something changes, then remove them once we're done.
Sometimes I'll set a DEBUG variable or dict. I also use pdb as needed,
eg import pdb; pdb.set_trace()
Emile
Not sure if the traceback
module can be helpful here!
Ch
x,x[1:]+[-1]) if jj != ii]
Emile
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
;ll need to
increase indentation level after any lines ending in a colon that
indicate the start of a block. This type of error can cause cryptic
messages to the thrown up that don't always point to the actual problem.
HTH,
Emile
#Validate the new feature class name for the output wo
101 - 200 of 527 matches
Mail list logo