Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-22 Thread Piet van Oostrum
e end. I don't think that's possible if you start as the user kk. >K> I don't know how to achieve this iffect. >K> Infact I will need this during a serious deployment because i would have >K> my application run as a demon as a dedicated user. >K> I

Re: Changing the private variables content

2009-07-22 Thread Piet van Oostrum
s assigned to variable print "Trying %s" % f if f == ("%s.py" % self._chosen_module): self._this_module = os.path.join(root, f) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-list Digest, Vol 70, Issue 282

2009-07-22 Thread Piet van Oostrum
>>>>> Ryniek90 (R) wrote: >R> " >R> Didn't worked, so i wil reuse your class, and modify it later. Now i see >R> that working on private objects complex. No it's not complex. *You* make it complex. -- Piet van Oostrum URL: http://pietvanoos

Re: Copy/paste through LAN

2009-07-23 Thread Piet van Oostrum
(I could list files in client's >J> window). >J> How can i pass the url information through Pyro ? What do you mean? Do you want to copy a file or copy file names? Copying a file between two machines can best be done by a specialized protocol, like HTTP or scp. Pasting a file doesn

Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread Piet van Oostrum
>>>>> Krishnakant (K) wrote: >K> On Thu, 2009-07-23 at 00:17 +0200, Piet van Oostrum wrote: >>> Being a sudoer is not a privilege to issue the os.setuid system call. It >>> is only a permission to use the sudo command. >>> >K> Yes, So I wo

Re: python function for retrieving key and encryption

2009-07-23 Thread Piet van Oostrum
>>>>> jayshree (j) wrote: >j> On Jul 21, 8:59 pm, Piet van Oostrum wrote: >>> The recipient_public_key.pem file is the public key of the recipient >>> which means the person that is going to receive the encrypted message. >>> You should get it

Re: challenging problem for changing to a dedicated non-privileged user within a script.

2009-07-23 Thread Piet van Oostrum
o and let it do a socket tunnelling to postgress, i.e. make a connection to the postgres server and a socket connection to the original Python script, and copy everything from one socket to the other - in both directions. However this can also be done with a ssh tunnel which might be simpler. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: sqlite3 performance problems only in python

2009-07-23 Thread Piet van Oostrum
lower ( NAME_ ) = 'fatigue' >SM>and TEST_COUNT in (3,4) >SM>and DATETIME > 39814.0 >SM>and SCORE < 30 1) Do you have indices on the join fields? 2) Look at the ANALYZE command 3) Look at the EXPLAIN command -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for os.listdir() generator

2009-07-23 Thread Piet van Oostrum
waling a directory with very many files' [sic!] Message id's: (ctypes) (Cython) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: What is file.encoding convention?

2009-07-24 Thread Piet van Oostrum
>>>>> Naoki INADA (NI) wrote: >NI> "Writing unicode to a file(-like)" is a simple requirement. >NI> Does python have any simple resolution for it? Yes, Python 3 will do this. For Python < 3.0 you will have to use a codecs wrapper or explicitely do the e

Re: effbot.org broken (WAS: Problems in commands.getoutput(cmd) with sox)

2009-07-24 Thread Piet van Oostrum
3&hl=en&ct=clnk&gl=us&client=firefox-a >CR> Anyone know what's the deal with effbot.org? It seems to be broken at >CR> present, forcing me to use Google's cached version. >CR> It's a real shame since it has lots of handy Python info. Just try again.

Re: mmap 2GB allocation limit on Win XP, 32-bits, Python 2.5.4

2009-07-24 Thread Piet van Oostrum
mpy.memmap using mmap.mmap On Windows XP the virtual address space of a process is limited to 2 GB unless the /3GB switch is used in the Boot.ini file. http://www.microsoft.com/whdc/system/platform/server/PAE/PAEmem.mspx -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4

Re: how to get no value

2009-07-24 Thread Piet van Oostrum
you write your code? Or look at it after you have written it? Sorry if I offend you but you give the impression of just trying some more or less random stuff and then asking here if it doesn't give the required result. That's not the attitude of a researcher, unless your definition of

Re: Convert points to polygon shapefile

2009-07-24 Thread Piet van Oostrum
>>>>> Luis Pedro Almeida (LPA) wrote: >LPA> Dear all, >LPA> I would like to know how to convert a list of points into a >LPA> polygon shapefile (esri). http://lmgtfy.com/?q=esri+shapefile+Python -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8

Re: non-owning references?

2009-07-24 Thread Piet van Oostrum
mutable >RJ> objects appear on the scene. While the OP appears to have the right idea, >RJ> your "correction" here could be quite misleading. If you read the OP, it is clear that he talked about a class variable, which is a perfectly legal notion in Python, and is mentioned as

Re: len() should always return something

2009-07-24 Thread Piet van Oostrum
gt;>> [Are there types for which len() returns a value that can't be >>> indexed?] >>> >RJ> Dictionaries. >RJ> Which doesn't make your point less valid. In fact I'd go so >RJ> far as to argue that what len() gives you is the numb

Re: Popen

2009-07-24 Thread Piet van Oostrum
r like os.waitpid(), subprocess.call() -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get no value

2009-07-24 Thread Piet van Oostrum
Well actually your subject is `how to get no value'. Your code does that perfectly. :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Predefined Variables

2009-07-24 Thread Piet van Oostrum
.php.net/index.php?everythingafterthequestionmark) as a >>>> single variable (rather than individual variables)? >>> os.environment('QUERY_STRING') >SDD> Maybe you mean: >SDD> os.environ['USER'] Let's take the best of both: os.environ[&

Re: ElementTree's Element substitution in Python 3

2009-07-24 Thread Piet van Oostrum
(most recent call last): >A> File "test.py", line 7, in >A> a[:] = c[:] >A> File "/usr/local/py3.1/lib/python3.1/xml/etree/ElementTree.py", line >A> 210, in __setitem__ >A> assert iselement(element) >A> AssertionError This is a

Re: pack an integer into a string

2009-07-24 Thread Piet van Oostrum
'0xf0cff00' >>>>> >s> so i would like a string like '\xf0\xcf\xf0\x00' You have the string wrong. But the correct one you get with: In [67]: import struct In [68]: number = 252509952 In [69]: struct.pack('>I', number) Out[69]: '

Re: len() should always return something

2009-07-25 Thread Piet van Oostrum
to all objects.) >S> Re errors passing silently, the OP doesn't believe that len(42) should be >S> an error, so that's not relevant. >S> And there's nothing ambiguous about len(42). len(42) should be 7.5 million. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: non-owning references?

2009-07-25 Thread Piet van Oostrum
the binding mechanisms in Java and Python are different I don't think the actual semantics are so much difference as to cause much confusion (with C it could be more). But such a study could reveal that. BTW. Which postings from (say) the last month did you have in mind? -- Piet van

Re: how can a child thread notify a parent thread its status?

2009-07-25 Thread Piet van Oostrum
also create a special sentinel object and use that. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-25 Thread Piet van Oostrum
ever, I've noticed that once a module is imported using the >r> `from pkg import mod' syntax, if its name is deleted from the >r> package namespace then subsequent imports with `from' will fail. This is incorrectly stated. Also on the initial import it will fail, not just on

Re: len() should always return something

2009-07-25 Thread Piet van Oostrum
cimal digits equally reasonable. More so than 1, actually. 1 as the length of an int doesn't give any information. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Why aren't OrderedDicts comparable with < etc?

2009-07-25 Thread Piet van Oostrum
are you >AvdH> want to know whether this is a map you already have encountered.] So what's the problem? piet$ python3 Python 3.1 (r31:73578, Jun 27 2009, 21:49:46) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "lic

Re: how can a child thread notify a parent thread its status?

2009-07-26 Thread Piet van Oostrum
ds, and the logger should count the sentinels which can have normal messages between them. It may be a bit fragile to depend on the number of threads especially when this number is dynamic. One solution would be to have special StartLogging and StopLogging objects that are put in the queue when

Re: Why doesn't `from pkg import mod' work after `del pkg.mod'?

2009-07-26 Thread Piet van Oostrum
>>>>> ryles (r) wrote: >r> On Jul 25, 8:57 am, Piet van Oostrum wrote: >>> >>>>> ryles (r) wrote: >>> >r> According tohttp://www.python.org/doc/essays/packages.html: >>> >r> "The import statement first tests wheth

Re: Looking for a dream language: sounds like Python to me.

2009-07-27 Thread Piet van Oostrum
c and integrated network support would be >DC> helpful. >DC> """ >DC> It looks to me like he is looking for Python. No fast, efficient binaries yet, and no integrated GUI builder. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: RSA cryptography between Python and Java

2009-07-27 Thread Piet van Oostrum
catch (IllegalBlockSizeException e) { System.out.println("Illegal block size" + e); } catch (NoSuchPaddingException e) { System.out.println("Illegal padding " + e); } catch (BadPaddingException e) { System.out.println(&quo

Re: open a file in python

2009-07-27 Thread Piet van Oostrum
>>>>> jayshree (j) wrote: >j> pk = open('/home/jayshree/my_key.public.pem' , 'rb').read() By the way, a PEM file is a text file, no reason to open it in binary mode. Just replace the 'rb' with 'r' or leave it out. -- Piet van

Re: RSA cryptography between Python and Java

2009-07-27 Thread Piet van Oostrum
>>>>> Michael Ströder (MS) wrote: >MS> Piet van Oostrum wrote: >>> Please note that the text to be encrypted must be smaller than the key >>> size (at least 11 bytes smaller). You shouldn't encrypt large data with >>> RSA anyway: it is too sl

Re: python function for retrieving key and encryption

2009-07-27 Thread Piet van Oostrum
g; encrypt() The above line should be shifted to the left. It is not part of the function otherwise you get an endless recursion. And to answer another question from stackoverflow.com: RSA.pkcs1_padding is a good parameter, if the decryption side will also use it. See also my posting on

Re: Discovery IP in connection

2009-07-27 Thread Piet van Oostrum
do you think the addr is for in data, addr = mySocket.recvfrom(100)? >DS> My source: >DS> #!/usr/bin/env python >DS> import socket >DS> mySocket = socket.socket ( socket.AF_INET, socket.SOCK_DGRAM ) >DS> mySocket.bind ( ( '', 514 ) ) >DS> data, addr = my

Re: The longest word

2009-07-28 Thread Piet van Oostrum
occurs twice still naturally easier if >N> also occured just once. >N> Sincere thanks & regards >N> Niklas 1. Is this homework? 2. It sounds very confusing. Are you trying to find the longest word in a series of words seperated by spaces? find and rfind will not help you much.

Re: The longest word

2009-07-28 Thread Piet van Oostrum
>>>>> NiklasRTZ (N) wrote: >N> Thank you. This seems to work: >N> sorted("a AAA aa a sdfsdfsdfsdf vv".split(' '),lambda a,b: len(a)- >N> len(b))[-1] >N> 'sdfsdfsdfsdf' simpler: sorted("a AAA aa a

Re: bad certificate error

2009-07-28 Thread Piet van Oostrum
# cert_file is a PEM formatted certificate chain file. >j> connection = httplib.HTTPSConnection(host, int(port), key_file, >j> cert_file) What happens if you set cert_file to None? This would indicate that you are not interested in the server's certificate. By th

Re: Semaphore Techniques

2009-07-29 Thread Piet van Oostrum
y versatile on most systems and can find >CB> specifically targeted processes like you program), and exit if there >CB> are already three. That will surely run into some race conditions. If the limit of 3 processes is soft then that wouldn't be a big deal, however. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with sql and python

2009-07-29 Thread Piet van Oostrum
? See http://mysql-python.sourceforge.net/MySQLdb.html This really has nothing to do with myphpadmin (you probably mean phpMyAdmin but even then it has nothing to do with it except that both acess a MySQL database). And if you give yourself a name than we might have an idea if we are talking to a

Re: open a file in python

2009-07-29 Thread Piet van Oostrum
eat asking the same or similar questions in different threads, especially if you don't take notice of the answers given. I will repeat it once here: load_pub_key requires a file name, not the contents of the file. So use rsa = M2Crypto.RSA.load_pub_key('my_key.public.pem') and

Re: New implementation of re module

2009-07-30 Thread Piet van Oostrum
nish, for example: >M> re.search(r"^(.+|D)*A$", "x" * 25 + "B") >M> which on my PC (1.8GHz) takes 18.98secs with the re module but <0.01secs >M> with this new implementation. Is this version also going to use the Thompson approach? -- Pi

Re: Semaphore Techniques

2009-07-30 Thread Piet van Oostrum
>>>>> Carl Banks (CB) wrote: >CB> On Jul 29, 7:14 am, Piet van Oostrum wrote: >>> >>>>> Carl Banks (CB) wrote: >>> >CB> On Jul 28, 3:15 pm, John D Giotta wrote: >>> >>> I'm looking to run a process with a lim

Re: Non-blocking read with popen subprocess

2009-07-31 Thread Piet van Oostrum
docs.python.org/library/ >JG> subprocess.html#popen-objects) which may be what you need. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: problem on socket programming

2009-07-31 Thread Piet van Oostrum
de error messages and full tracebacks. >>> >>> Cheers, >>> Chris >>> --http://blog.rebertia.com >M> these are errors : >M> Traceback (most recent call last): >M> File "echo-client.py", line 11, in M> sockobj.connect((serverHost,

Re: Processes not exiting

2009-07-31 Thread Piet van Oostrum
arallel,args= >m> (hard_work_queue,result_queue,))) >m> #wait for all hard workers to finish >m> for worker in hard_workers: >m> worker.join() Here you create new hard workers, but you never start them. The join should then give an exception when it reaches these. -- Pi

Re: socket policy flash help

2009-08-01 Thread Piet van Oostrum
rawinput = str('version=\"1.0\"?>to-ports=\"*\" />') The str here is unnecessary as you have already a string. >N> print (rawinput) >N> b = bytes ( ord(c) for c in raw

Re: Newbie thwarted by sys.path on Vista

2009-08-01 Thread Piet van Oostrum
variable or to the PythonPath key in the registry. However, PYTHONPATH >MMM> doesn't exist, Then create it. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Get Cliet IP Address

2009-08-02 Thread Piet van Oostrum
ot;) or getenv("HTTP_X_FORWARDED_FOR") or getenv("HTTP_X_FORWARDED_FOR") or getenv("REMOTE_ADDR") or "UNKNOWN") I use getenv() rather than environ[] to avoid exceptions. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE1

Re: cgi script

2009-08-02 Thread Piet van Oostrum
exception trace in your browser (if it gets that far, that is). import cgitb cgitb.enable() -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: socket policy flash help

2009-08-02 Thread Piet van Oostrum
ains the byte sequence that starts with a b, then a ' ... and ending with the 5 bytes \ x 0 0 ' which is wrong. Actually it should be: if buff == b\'\x00': or if buff == b\'\0': >N> print ('policy FOUND >>> sending...') >N&g

Re: Processes not exiting

2009-08-02 Thread Piet van Oostrum
ed. I wonder if something fishy is happening in the multiprocessing infrastructure. Or maybe the Fortran code goes wrong because it has no protection against buffer overruns and similar problems, I think. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private ema

Re: Executing remote command with paramiko

2009-08-03 Thread Piet van Oostrum
e, port, username, password) t = s.get_transport() chan = t.open_session() chan.exec_command('sudo -s') print 'writing password' chan.send(password + '\n') print 'write command' chan.send('whoami\n') print "try to read" print chan.recv() For more control you can use chan.recv_ready() to see if output is available. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Special chars with HTMLParser

2009-08-05 Thread Piet van Oostrum
yref(self, name): print 'char:', unichr(name2codepoint[name]) If your HTML may be illegal you should add some exception handling. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble with complex numbers

2009-08-05 Thread Piet van Oostrum
t int, long, float to complex That should be z += 0j >CH> return atan2(z.imag, z.real) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Special chars with HTMLParser

2009-08-05 Thread Piet van Oostrum
nicode letters), and that the new stuff also consists of letters. If your language has additional word constituents like - or ' you have to add this. You can do this with unicodedata.category or with a regular expression. If your locale is correct \w in a regular expression may be helpful. -- Piet

Re: Is this a bug in multiprocessing or in my script?

2009-08-05 Thread Piet van Oostrum
Calling os.exit in a child process may be dangerous. It can cause unflushed buffers to be flushed twice: once in the parent and once in the child. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: http access produces 503

2009-08-05 Thread Piet van Oostrum
10 socket.setdefaulttimeout(timeout) try: response = opener.open(url) print response.read() print"ok = 1" except: print "error 1" >R> output from the above: >R> Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/ >R> 20071127 Firefox/2.0.0.11 >R> error 1 >R> Error code: 503 >R> ('Service Unavailable', 'The server cannot process the request due to >R> a high load') That suggests that there is a real problem in the server. Or that your url causes some problems. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Python to automate builds

2009-08-06 Thread Piet van Oostrum
ent. I don't think there is any modern OS that allows that. Unless you use your own protocol of course, like letting the child write the environment to its stdout and reading and interpreting it in the parent. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]

Re: Web page data and urllib2.urlopen

2009-08-06 Thread Piet van Oostrum
x27; t know any way >DA> a CSS file could cause the content to change, just the display. >DA> All I can guess is that it has something to do with "browser type" or >DA> cookies. And that would make lots of sense if this was a cgi page. But >DA> the URL doesn't look like that, as it doesn't end in pl, py, asp, or any of >DA> another dozen special suffixes. >DA> Any hints, anybody??? If you look into the HTML that Firefox gets, there is a lot of javascript in it. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Web page data and urllib2.urlopen

2009-08-07 Thread Piet van Oostrum
>>>>> Dave Angel (DA) wrote: >DA> Piet van Oostrum wrote: >>> >DA> If Mozilla had seen a page with this line in an appropriate place, it'd >DA> immediately begin loading the other page, at "someotherurl" But there's no >DA>

Re: problem

2009-08-07 Thread Piet van Oostrum
you can better look into the general 'grep'-like software. For example start here: http://arglist.com/regex/ -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Web page data and urllib2.urlopen

2009-08-07 Thread Piet van Oostrum
>>>>> Dave Angel (DA) wrote: >DA> Piet van Oostrum wrote: >>>>>>>> >>>>>>>> >>> >DA> But the raw page didn't have any javascript. So what about that original >DA> raw page triggered additional stuf

Re: how to kill subprocess when Python process is killed?

2009-08-07 Thread Piet van Oostrum
iated. When the parent dies, the child should die when it's writing on the broken pipe. At least that's how it works in Unix systems. I don't know about Windows, however. To let the dying be fast you should make sure that stdout in the child is unbuffered. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: help with threads

2009-08-07 Thread Piet van Oostrum
f the C code is not manipulating Python objects or something in the Python interpreter, it could be changed to release the GIL during the computation. That's also how Numpy does it, IIRC. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.o

Re: Problem with join in__str__() in class (newbie)

2009-08-09 Thread Piet van Oostrum
7;e1', 'Albert', [topic1]) expert2 = Expert('e2', 'Leonhard', [topic2]) expert1.add_expert(expert2) expert5 = Expert('e5', 'Carla', [topic5, topic6]) expert5.add_expert(expert1) expert5.add_expert(expert2) for ex in expert1, ex

Re: reloading the module imported as 'from ... import ...'

2009-08-10 Thread Piet van Oostrum
ot;credits" or "license" for more information. >>> import testmod >>> from testmod import TestClass >>> a = TestClass() >>> b = TestClass() >>> a.__class__ is b.__class__ True >>> reload(testmod) >>> c = TestClass() >>> c.__class__ is a.__class__ True >>> from testmod import TestClass >>> d = TestClass() >>> d.__class__ is a.__class__ False -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem Regarding Handling of Unicode string

2009-08-10 Thread Piet van Oostrum
নেক Or if you write to a file, open it with utf-8 encoding. I take utf-8 because in general this is the preferred encoding for non-ASCII text. It could be that Bengali has a different preferred encoding. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem when fetching page using urllib2.urlopen

2009-08-10 Thread Piet van Oostrum
-485468-pune_india_vacations-i;_ylc=X3oDMTFka28zOGNuBF9TAzI3NjY2NzkEX3MDOTY5NTUzMjUEc2VjA3NzcC1kZXN0BHNsawN0aXRsZQ--' hdrs = {'User-Agent': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.13) Gecko/2009073021 Firefox/3.0.13', 'Accept': '

Re: www.python.org website is down?

2009-08-10 Thread Piet van Oostrum
; attic on an old Linux box :-) >M> That was a quote from A.M. Kuchling. >M> It's actually hosted on a matchbox-sized multi-core multi-terabyte >M> wifi-enabled Linux machine that Guido brought back from 2050. >M> Unfortunately, the dog ate it, so he's had to go a

Re: Search and write to .txt file

2009-08-11 Thread Piet van Oostrum
he exact >H> number of bytes. >H>break# leave loop once '1' is found Mixing an iterator on the file with direct calls (seek/write) isn't going to work. The iterator does read ahead which causes the file position not to be

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Piet van Oostrum
quences' for a reason: that they are not in standard C++. test.cpp: char* temp = "abc\yz"; TEMP> g++ -c test.cpp test.cpp:1:1: warning: unknown escape sequence '\y' -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: something like perl's Mail::GPG ?

2009-08-14 Thread Piet van Oostrum
g.msg').read() cl = clarify(msgtxt) gpg=GPG(gnupghome = os.path.join(os.environ['HOME'], '.gnupg')) if gpg.verify(cl): print "Signature correct" else: print "Signature incorrect" -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting on '^' ?

2009-08-14 Thread Piet van Oostrum
['spam\nham\neggs\n'] >>>>> bol_re = re.compile('^', re.M) >>>>> bol_re.split('spam\nham\neggs\n') >k> ['spam\nham\neggs\n'] >k> Am I doing something wrong? It says that in the doc of 're': Note that split

Re: Need cleanup advice for multiline string

2009-08-17 Thread Piet van Oostrum
ice from a woman? lol. Thanks for the help. >SB> Give the attitudes still prevalent in our industry (cf >SB> <http://tinyurl.com/c5nqju> and many more), I'm sorry to say that I >SB> don't think this is funny. seconded -- Piet van Oostrum URL: http://pietvanoostr

Re: zip codes

2009-08-17 Thread Piet van Oostrum
t;GE> expressions of information. A particular publication >GE> containing zip code information can be copyrighted. The >GE> underlying facts themselve cannot be. But that doesn't help you if you need that information and the only way to obtain it is from copyrighted sources. -- Pi

Re: recording input from USB port and write to text file

2009-08-19 Thread Piet van Oostrum
;A> file and I am so lost. Can anyone help or direct me to some >A> resources? Thank you! You could try http://sourceforge.net/projects/pyusb/ -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Subclass dynamically

2009-08-19 Thread Piet van Oostrum
should be a class, therefore MyBase should be a metaclass. Or is that not what you want? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Python and PHP encryption/decryption

2009-08-21 Thread Piet van Oostrum
which is available for most platforms that have Python whereas Pycrypto has its own C implementations of crypto algorithms. M2crypto has a recent release. Also I think because OpenSSL is widely used, its vulnerabilities are easier detected and corrected, whereas I don't think that is the case

Re: Annoying octal notation

2009-08-21 Thread Piet van Oostrum
gt; someone might accidentally type (or intentionally type, having to do >DM> this in dozens of other programming languages). You're right. Either hexadecimal should have been 0h or octal should have been 0t :=) -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private ema

Re: How to 'de-slashify' a string?

2009-08-22 Thread Piet van Oostrum
t;VB> ö >>>>> >VB> It might be an IDLE issue, but it still isn't one unicode glyph. >VB> I guess, you have to ensure, that the input data is valid and the >VB> right encoding is used. >>> decoded = '\\303\\266'.decode(&qu

Re: string literal vs string variable

2009-08-22 Thread Piet van Oostrum
ng variable and a literal >KN> string. Is the difference as simple as: >KN> somestring = u'hello world' >KN> fromstring(somestring) <-- string variable >KN> vs >KN> XML(u'hello world') <-- literal string Yes. Stefan probably means

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-24 Thread Piet van Oostrum
gt;SDD> .3.100 == 9 (trinary) >SDD> .Z.100 == 46656 (base 36) I wonder how you wrote that interpreter, given that some answers are wrong. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
cation for data. Of course they do, but a significant portion of a Python system consists of imported modules and these are data as far as the OS is concerned. Only the modules written in C which are loaded as DLL's (shared libs) and of course the interpreter executable will be share

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
e the >>> executable (interpreter) code, and only create a new stack/heap >>> allocation for data. >>> >DA> That's what fork is all about. (See os.fork(), available on most >DA> Unix/Linux) The two processes start out sharing their state, and only the >DA

Re: basic thread question

2009-08-24 Thread Piet van Oostrum
>>>>> sturlamolden (s) wrote: >s> On 24 Aug, 13:21, Piet van Oostrum wrote: >>> But os.fork() is not available on Windows. And I guess refcounts et al. >>> will soon destroy the sharing. >s> Well, there is os.fork in Cygwin and SUA (SUA is the Un

Re: basic thread question

2009-08-25 Thread Piet van Oostrum
>>>>> sturlamolden (s) wrote: >s> On 25 Aug, 01:26, Piet van Oostrum wrote: >>> That's because it doesn't use copy-on-write. Thereby losing most of its >>> advantages. I don't know SUA, but I have vaguely heard about it. >s> SUA is a

Re: conditional for-statement

2009-08-25 Thread Piet van Oostrum
ct) You can also say: [x+y for x in range(3) for y in range(4) if x < y] If you want to write this as a loop you have to put the for's on separate lines separated by colons, so why not the if also? Or would you also like to have the for's on one line? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: print() and unicode strings (python 3.1)

2009-08-26 Thread Piet van Oostrum
locale >7> LANG= >7> LC_COLLATE="C" >7> LC_CTYPE="C" >7> LC_MESSAGES="C" >7> LC_MONETARY="C" >7> LC_NUMERIC="C" >7> LC_TIME="C" >7> LC_ALL="C" IIRC, Mac OS X 10.4 does not set LANG

Re: Web Services examples using "raw" xml?

2009-08-26 Thread Piet van Oostrum
of roadblocks that have left >>> me frustrated. >DBR> Welcome to the wonderful world of SOAP. If you didn't know - the S stands >DBR> for simple [1]. Stood. Like the O was supposed to stand for Object. Now out of shame they tend to talk more about `Service Orie

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-27 Thread Piet van Oostrum
>>>>> Mensanator (M) wrote: >M> On Aug 26, 4:59 pm, Piet van Oostrum wrote: >>> >>>>> Mensanator (M) wrote: >>> >M> That's my point. Since the common usage of "binary" is for >>> >M> Standard Positional

Re: TypeError: _getfullpathname() argument 1 must be (buffer overflow), not str in windows xp, while making tarfile

2009-08-27 Thread Piet van Oostrum
le the posted code has only 188 lines? -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with Python scoping rules

2009-08-27 Thread Piet van Oostrum
nction that motivated this post would be considerably more >k> difficult to explain and would have obscured the point of the post. Classes don't have helper functions; they have methods. Instance methods, static methods or class methods. Your's isn't either of these. Methods a

Re: TypeError: _getfullpathname() argument 1 must be (buffer overflow), not str in windows xp, while making tarfile

2009-08-27 Thread Piet van Oostrum
Thanks, now works fine. :-) >>>> >>> >>> And, by the way, how come the traceback refers to >>> File "backuper.py", line 197, in >>> while the posted code has only 188 lines? >>> >R> Cuz my original code is bit longer - i

Re: How to unencode a string

2009-08-27 Thread Piet van Oostrum
ng like Word1%20Word2%20Word3 I want to get Word1 >j> Word2 Word3. urllib.unquote(string) >j> Would also like to handle special characters like '",(){} >j> [] etc/ What would you like to do with them? Or do you mean to replace %27 by ' etc? -- Piet van Oostr

Re: Select column from a list

2009-08-28 Thread Piet van Oostrum
n! I can't see why. If you work with matrices, numpy may be interesting for you. It does have the required functionality: M[:,0] will give you the first column. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: Numeric literals in other than base 10 - was Annoying octal notation

2009-08-30 Thread Piet van Oostrum
e customary meaning of `unary' is the tally system, as a radix system wouldn't make sense. I don't know when this term came into use but I have known it for a long time. -- Piet van Oostrum URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org -- http://mail.python.org/mailman/listinfo/python-list

Re: map

2009-08-31 Thread Piet van Oostrum
woofer is much harder to follow than map, I think. [myFunc(elt, 'booHoo') for elt in myList] is also a good candidate and in this case I think it is preferable to both the loop and the map with a partial or lambda in terms of clarity. On the other hand when you just want to call a function

Re: Is behavior of += intentional for int?

2009-08-31 Thread Piet van Oostrum
t in Python or whether that is to be considered strange should depend on the availability of a floating point unit in the hardware where the program runs? Would that make floating point numbers "fundamentally different" from ints in the sense described above? -- Piet van Oo

Re: Is behavior of += intentional for int?

2009-09-01 Thread Piet van Oostrum
ehave as constant value; 2) mutable numbers, which behave as >z> variable value? Numbers are immutable by nature (math). The number 3.14 remains 3.14 whatever you try to do with it. What you call an immutable number is in fact a container that contains a number. You can change the contents of

<    2   3   4   5   6   7   8   >