http://www.redcanary.ca/view/top-programming
Dick Moores
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Thank you, this is great.
Alan Gauld wrote:
Norman Khine [EMAIL PROTECTED] wrote
q_keys.sort()
a = [q[x] for x in q_keys]
a = [random.choice(q[x]) for x in q_keys]
So from this how do I choose a random element and produce a new
dictionary like for example:
See above.
--
Happy Deer [EMAIL PROTECTED] wrote
def getdata(varlist):
eventually I have a variable called data, which have exactly the
same
number of columns as the name of variables in varlist.
Say varlist=['var1','var2','var3']. I want to assign
var1=data[:,0],
var2=data[:,1],
Dick Moores [EMAIL PROTECTED] wrote
http://www.redcanary.ca/view/top-programming
Interesting, but I'm not sure what the criteria for top is.
Is it a measure of power, popularity, usage?
Scary that HTML/CSS should be so high though
given its not a programming language at all!
Alan G.
Alan Gauld wrote:
Dick Moores [EMAIL PROTECTED] wrote
http://www.redcanary.ca/view/top-programming
Interesting, but I'm not sure what the criteria for top is.
Is it a measure of power, popularity, usage?
Scary that HTML/CSS should be so high though
given its not a programming
On 07/10/2007, Ricardo Aráoz [EMAIL PROTECTED] wrote:
Alan Gauld wrote:
Dick Moores [EMAIL PROTECTED] wrote
http://www.redcanary.ca/view/top-programming
Interesting, but I'm not sure what the criteria for top is.
Is it a measure of power, popularity, usage?
Scary that HTML/CSS
What are these stats based on?
On 10/7/07, Alan Gauld [EMAIL PROTECTED] wrote:
Dick Moores [EMAIL PROTECTED] wrote
http://www.redcanary.ca/view/top-programming
Interesting, but I'm not sure what the criteria for top is.
Is it a measure of power, popularity, usage?
Scary that HTML/CSS
Alan Gauld wrote:
The notation data[;,0] doesn't make sense and is an error in Python.
I#m not sure what you think it does. I assume you simply mean
data[0]?
[:,0] is an extended slice, not an error:
http://docs.python.org/ref/slicings.html
It is used in Numeric/numpy to select from
Christopher Spears wrote:
One of the exercises from Core Python Programmng (2nd
Edition) asks me to determine the largest and smallest
integers, float, and complex numbers my system can
handle. Using python.org and Google, I have
discovered my system's largest and smallest ingtegers:
Kent Johnson [EMAIL PROTECTED] wrote
The notation data[;,0] doesn't make sense and is an error in
Python.
[:,0] is an extended slice, not an error:
http://docs.python.org/ref/slicings.html
Really? I got an error from the interpreter.
d[:,0]
Traceback (most recent call last):
File
Alan Gauld wrote:
Kent Johnson [EMAIL PROTECTED] wrote
The notation data[;,0] doesn't make sense and is an error in
Python.
[:,0] is an extended slice, not an error:
http://docs.python.org/ref/slicings.html
Really? I got an error from the interpreter.
d[:,0]
Traceback (most recent
Kent Johnson wrote:
Alan Gauld wrote:
Kent Johnson [EMAIL PROTECTED] wrote
The notation data[;,0] doesn't make sense and is an error in
Python.
[:,0] is an extended slice, not an error:
http://docs.python.org/ref/slicings.html
We discussed this quite a bit last July:
Hi everyone,
I'm working on making a Debian package for a game I'm working on, and it
works fine, but I've run into a problem with my script now. The script is
placed in /usr/bin so all users on the system have access, but even though
it will run fine, I can't save files to that directory, so the
Hello tutors,
I am adding logging to a program I am writing. I have some messages I want to
log that are rather long. The problem I am running into is that when the line
is more than the 80 character line recommendation and I split it across 2 lines
with \, the output is affected.
Example
Thank all for the discussion.
Maybe I can separate my question into two.
First, I have experience in Matlab, where I can use eval. I wonder whether
someone knows about it.
Second, if I just want to return data[:,1], ...data[:,-1] separately without
knowing ahead how many columns data has. What
Sent this almost an hour ago, did not get it from the list yet. No idea why,
but sending again...
--
Hello tutors,
I am adding logging to a program I am writing. I have some messages I want to
log that are rather long. The problem I am running into is that when the line
David Millar wrote:
Hi everyone,
I'm working on making a Debian package for a game I'm working on, and
it works fine, but I've run into a problem with my script now. The
script is placed in /usr/bin so all users on the system have access,
but even though it will run fine, I can't save
Dear all-
I wonder whether there is a way in Python which can do what eval in
Matlab does.
Say, varlist is a 1 by k tuple/list, which contains strings for variable
names.
For example, varlist=['var1','var2',...'vark']
data is a n by k matrix.
I want to assign each column in data to each variable
Happy Deer wrote:
Thank all for the discussion.
Maybe I can separate my question into two.
First, I have experience in Matlab, where I can use eval. I wonder
whether someone knows about it.
Second, if I just want to return data[:,1], ...data[:,-1] separately
without knowing ahead how
I am writing a function getdata for other people, and I want others can use
the function as follows.
var1,var2, var3=getdata(..., ['var1','var2','var3'],...)
If I can not return data column by column, I can not get the above, right?
On 10/7/07, Eric Brunson [EMAIL PROTECTED] wrote:
Happy Deer
if os.name == posix:
fname = ~/ + fname
infile = open(fname,w)
you must expand '~' before open:
fname = os.path.join('~',fname)
fname = os.path.expanduser( fname )
infile = open(fname,'w')
___
Tutor
dont indent the line after '\', that means 0 indent
s = 'hello\
boy'
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Happy Deer wrote:
First, I have experience in Matlab, where I can use eval. I wonder
whether someone knows about it.
Python has an eval() function but it's use is discouraged, there is
usually a better way. It would help if you would give us more context
for your problem.
Second, if I
Happy Deer wrote:
I am writing a function getdata for other people, and I want others
can use the function as follows.
var1,var2, var3=getdata(..., ['var1','var2','var3'],...)
If I can not return data column by column, I can not get the above,
right?
Given:
data = [ 1, 2, 3, 4, 5, 6 ]
A good python coder would probably not choose to pollute his name space
like that. My choice would be to assign the elements of data to a
dictionary indexed by the strings in varlist like this:
vardict = dict( zip( varlist, data ) )
and reference var1 as:
vardict['var1']
Happy Deer wrote:
claxo wrote:
dont indent the line after '\', that means 0 indent
s = 'hello\
boy'
Or, arguably better:
s = '''hello
boy'''
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
wormwood_3 wrote:
Hello tutors,
I am adding logging to a program I am writing. I have some messages I want to
log that are rather long. The problem I am running into is that when the line
is more than the 80 character line recommendation and I split it across 2
lines with \, the output
Happy Deer wrote:
I am writing a function getdata for other people, and I want others can
use the function as follows.
var1,var2, var3=getdata(..., ['var1','var2','var3'],...)
There is no need to pass the variable names to getdata.
Have you read any Python tutorials? There are several good
However, I didn't actually answer your question.
As Kent has already mentioned, eval is quite dangerous in python and to
be avoided when possible. I think it would be safer to do something
like this:
l = locals()
for x, y in zip( varlist, data ):
l[x] = y
or, more tersely:
[
Happy Deer wrote:
Dear all-
I wonder whether there is a way in Python which can do what eval in
Matlab does.
Say, varlist is a 1 by k tuple/list, which contains strings for variable
names.
For example, varlist=['var1','var2',...'vark']
data is a n by k matrix.
I want to assign each
Eric Brunson wrote:
claxo wrote:
dont indent the line after '\', that means 0 indent
s = 'hello\
boy'
Or, arguably better:
s = '''hello
boy'''
That is a different string, it contains a newline, the original does not:
In [20]: s = 'hello\
: boy'
In [21]: s2 = '''hello
Eric Brunson wrote:
However, I didn't actually answer your question.
As Kent has already mentioned, eval is quite dangerous in python and to
be avoided when possible. I think it would be safer to do something
like this:
l = locals()
for x, y in zip( varlist, data ):
l[x] = y
logger.info(Checked %s records in %s seconds, yielding an average of
\
%s seconds per record. % (len(self.data), duration, avgquery) )
^
Remove these spaces. It makes the source code look weird, but the
output will be correct.
Alan
On Sunday 07 October 2007 21:29, Happy Deer wrote:
Thank all for the discussion.
Maybe I can separate my question into two.
First, I have experience in Matlab, where I can use eval. I
wonder whether someone knows about it.
I suspect you are using Numpy, you should subscribe to the Numpy
On Sunday 07 October 2007 22:32, Kent Johnson wrote:
Eric Brunson wrote:
claxo wrote:
dont indent the line after '\', that means 0 indent
s = 'hello\
boy'
Or, arguably better:
s = '''hello
boy'''
And there is even a third way:-)
s = hello \
... world.
s
'hello
I have written the exact same reply. Sorry for that! I should have
read the other replies first.
Eike.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hello all,
I have a tree of code on a machine which has been tweaked and fiddled
with over several months, and which passes tests.
I have the same codebase in a new virtual machine. A shell hack[0]
shows me that the permissions are very different between the two.
I could use rsync or something
Stephen Nelson-Smith [EMAIL PROTECTED] wrote
I could use rsync or something to synchronise them, but I would like
to produce a report of the sort:
Change file: foo from 755 to 775
I'm not sure how best to proceed - I guess walk through the
filesystem
gathering info using stat, then do
Hello all,
I have a script which takes data from a file or MySQL DB, looks up some stuff,
then can print results to console or file. I would also like it to be able to
update a MySQL database with the results. Does anyone have any ideas on how to
do this? I can update records just fine, but
wormwood_3 wrote:
Hello all,
I have a script which takes data from a file or MySQL DB, looks up some
stuff, then can print results to console or file. I would also like it to be
able to update a MySQL database with the results. Does anyone have any ideas
on how to do this? I can update
Alan Gauld wrote:
There is a dircmp module that may do what you want but I've not
used it.
It was deprecated in Python 2.0 and removed in 2.5. From a quick look it
might provide a useful framework but it doesn't compare permissions.
Kent
___
Tutor
wormwood_3 wrote:
Hello all,
I have a script which takes data from a file or MySQL DB, looks up some
stuff, then can print results to console or file. I would also like it to be
able to update a MySQL database with the results. Does anyone have any ideas
on how to do this? I can update
On Sun, Oct 07, 2007 at 06:07:45PM -0700, wormwood_3 wrote:
Hello all,
I have a script which takes data from a file or MySQL DB, looks up
some stuff, then can print results to console or file. I would also
like it to be able to update a MySQL database with the results. Does
anyone have any
Hey Sam,
wormwood_3 wrote:
Hello all,
I have a script which takes data from a file or MySQL DB, looks up some
stuff, then can print results to console or file. I would also like it to be
able to update a MySQL database with the results. Does anyone have any ideas
on how to do this? I can
Thanks - it still took a bit more tweaking because of how I wrote a few
things, but the saving works fine now. I've been having trouble with finding
a version of the curses library for Windows that I can get working, so I
just used os.path.expanduser no matter the system. :/
Dave
On 10/7/07,
Rick Pasotto wrote:
(ip,fqdn) = line.split(',')
updatequery = update resultstable set %s where ip = %s % (fqdn,ip)
cursor.execute(updatequery)
connection.close()
Alternatively you could do:
connection = MySQLdb.connect(db=self.todatabase,host-self.host,
46 matches
Mail list logo