decouple copy of a list

2010-12-10 Thread Dirk Nachbar
I want to take a copy of a list a

b=a

and then do things with b which don't affect a.

How can I do this?

Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: decouple copy of a list

2010-12-10 Thread Dirk Nachbar
On Dec 10, 1:56 pm, Wolfgang Rohdewald wolfg...@rohdewald.de wrote:
 On Freitag 10 Dezember 2010, Dirk Nachbar wrote:

  I want to take a copy of a list a

  b=a

  and then do things with b which don't affect a.

  How can I do this?

  Dirk

 b=a[:]

 --
 Wolfgang

I did that but then some things I do with b happen to a as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: playful coding problems for 10 year olds

2010-11-01 Thread Dirk Nachbar
This is in JS but have a look here http://github.com/ryanmcgrath/splash

On 1 Nov, 20:31, Daniel Fetchinson fetchin...@googlemail.com wrote:
 Hi folks,

 My niece is interested in programming and python looks like a good
 choice (she already wrote a couple of lines :)) She is 10 and I
 thought it would be good to have a bunch of playful coding problems
 for her, stuff that she could code herself maybe after some initial
 help.

 Do you guys know problems like these? Or a good resource where to look them 
 up?

 Cheers,
 Daniel

 --
 Psss, psss, put it down! -http://www.cafepress.com/putitdown

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using google app through python

2010-11-01 Thread Dirk Nachbar
Why don't you start here 
http://code.google.com/apis/spreadsheets/data/1.0/developers_guide_python.html

On 1 Nov, 09:05, charu gangal charugan...@gmail.com wrote:
 Hey! Can anyone help me with python script for reading google
 spreadsheets? what all packages do i need to import to make the code
 run successfully after deploying it on google environment..thnx in
 advance

-- 
http://mail.python.org/mailman/listinfo/python-list


direct print to log file

2010-10-05 Thread Dirk Nachbar
How can I direct all print to a log file, eg some functions have their
own print and I cannot put a f.write() in front of it.

Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list


Numpy on 2.7

2010-09-20 Thread Dirk Nachbar
I am trying to install Numpy on Python 2.7 but it only looks for 2.6
folder, how can I change that?

Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list


freq function

2010-08-22 Thread Dirk Nachbar
Here is a function which takes any list and creates a freq table,
which can be printed unsorted, sorted by cases or items. It's supposed
to mirror the proc freq in SAS.

Dirk

def freq(seq,order='unsorted',prin=True):
#order can be unsorted, cases, items

freq={}
for s in seq:
if s in freq:
freq[s]+=1
else:
freq[s]=1
if prin==True:
print 'Items=',len(seq),'Cases=',len(freq)
print ''
if order=='unsorted':
for k in freq.keys():
print k,freq[k],float(freq[k])/len(seq)
elif order=='cases':
#http://blog.client9.com/2007/11/sorting-python-dict-by-
value.html
freq2=sorted(freq.iteritems(), key=lambda (k,v):
(v,k),reverse=True)
for f in freq2:
print f[0],f[1],float(f[1])/len(seq)
elif order=='items':
for k in sorted(freq.iterkeys()):
print k,freq[k],float(freq[k])/len(seq)
print ''
return freq

#test

import random

rand=[]
for i in range(1):
rand.append(str(int(100*random.random(

fr=freq(rand)
fr2=freq(rand,order='items')
fr2=freq(rand,order='cases')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Urrlib2 IncompleteRead error

2010-07-27 Thread Dirk Nachbar
Thanks, I don't think it's redirecting, how can I increase the timeout?

On 27 July 2010 16:56, Nitin Pawar nitinpawar...@gmail.com wrote:

 Hi,

 Check if the webpage you are trying to access is redirecting the page to
 some other page?
 or the timeout is too less for the request to finish


 Thanks,
 Nitin

 On Tue, Jul 27, 2010 at 7:30 PM, dirknbr dirk...@gmail.com wrote:

 I am running urllib2.request and get this response when I do the read.
 Any ideas what causes this?

 return response.read()
  File C:\Python26\lib\socket.py, line 329, in read
data = self._sock.recv(rbufsize)
  File C:\Python26\lib\httplib.py, line 518, in read
return self._read_chunked(amt)
  File C:\Python26\lib\httplib.py, line 561, in _read_chunked
raise IncompleteRead(''.join(value))
 IncompleteRead: IncompleteRead(3235 bytes read)

 Dirk
 --
 http://mail.python.org/mailman/listinfo/python-list




 --
 Nitin Pawar




-- 
http://twitter.com/dirknbr
http://maximum-likely.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Email in 2.6.4

2010-05-24 Thread Dirk Nachbar
Sorry guys, I had named my file email.py and hence the error.



On 24 May 2010 15:22, Jean-Michel Pichavant jeanmic...@sequans.com wrote:

 dirknbr wrote:

 I have now easy_installled email and I still get errors.


 It doesn't error on 'import email' but does on call to MimeText.

 import email
 msg = MIMEText('test')

 NameError: name 'MIMEText' is not defined

 What should I do?


 Using easy_install will not prevent the standard lib to be shadowed by
 another (user) module.

 did you print email.__file__ to verify the path ?
 Can you show us the output ?

 To give you an example, on a lenny python 2.5 distrib, the MIMEText class
 is in
 /usr/lib/python2.5/email/mime/text.py

 JM




-- 
http://dirknbr.googlepages.com
http://maximum-likely.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list