Re: Help with implementing callback functions using ctypes

2013-05-09 Thread Nobody
On Wed, 08 May 2013 04:19:07 -0700, jamadagni wrote: > I have the below C program spiro.c (obviously a simplified testcase) > which I compile to a sharedlib using clang -fPIC -shared -o libspiro.so > spiro.c, sudo cp to /usr/lib and am trying to call from a Python script > spiro.py using ctypes. H

Re: object.enable() anti-pattern

2013-05-10 Thread Nobody
On Thu, 09 May 2013 05:23:59 +, Steven D'Aprano wrote: > There is no sensible use-case for creating a file without opening it. > What would be the point? Any subsequent calls to just about any method > will fail. Since you have to open the file after creating the file object > anyway, why m

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Nobody
On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote: > Aside: Why was PHP's /e regexp option ever implemented? Because it's a stupid idea, and that's the only requirement for a feature to be implemented in PHP. -- http://mail.python.org/mailman/listinfo/python-list

Re: Short-circuit Logic

2013-05-27 Thread Nobody
On Sun, 26 May 2013 04:11:56 -0700, Ahmed Abdulshafy wrote: > I'm having a hard time wrapping my head around short-circuit logic that's > used by Python, coming from a C/C++ background; so I don't understand why > the following condition is written this way!> > > if not allow_zero and abs(x)

Re: Short-circuit Logic

2013-05-27 Thread Nobody
On Mon, 27 May 2013 13:11:28 -0700, Ahmed Abdulshafy wrote: > On Sunday, May 26, 2013 2:13:47 PM UTC+2, Steven D'Aprano wrote: > >> What the above actually tests for is whether x is so small that (1.0+x) >> cannot be distinguished from 1.0, which is not the same thing. It is >> also quite arbitrar

Re: Short-circuit Logic

2013-05-30 Thread Nobody
On Thu, 30 May 2013 12:07:40 +0300, Jussi Piitulainen wrote: > I suppose this depends on the complexity of the process and the amount > of data that produced the numbers of interest. Many individual > floating point operations are required to be within an ulp or two of > the mathematically correct

Re: Short-circuit Logic

2013-05-30 Thread Nobody
On Thu, 30 May 2013 19:38:31 -0400, Dennis Lee Bieber wrote: > Measuring 1 foot from the 1000 foot stake leaves you with any error > from datum to the 1000 foot, plus any error from the 1000 foot, PLUS any > azimuth error which would contribute to shortening the datum distance. First, let's

Re: Create a file in /etc/ as a non-root user

2013-05-31 Thread Nobody
On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote: > I am a python novice;request all to kindly bear with me. > > fd = open('/etc/file','w') > fd.write('jpdas') > fd.close() > > > The above snippet fails with: > IOError: [Errno 13] Permission denied: '/etc/file' As it should. > Any Idea ho

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-02 Thread Nobody
On Sat, 01 Jun 2013 08:44:36 -0700, Νικόλαος Κούρας wrote: > CalledProcessError: Command '/home/nikos/public_html/cgi-bin/files.py' > returned non-zero exit status 1 > args = (1, '/home/nikos/public_html/cgi-bin/files.py') > cmd = '/home/nikos/public_html/cgi-bin/files.py' >

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Nobody
On Mon, 03 Jun 2013 23:28:21 -0700, nagia.retsina wrote: > I can't believe Chrome whcih by default uses utf8 chosed iso-8859-1 to > presnt the filenames. Chrome didn't choose ISO-8859-1, the server did; the HTTP response says: Content-Type: text/html;charset=ISO-8859-1 -- http://mail.python

Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-04 Thread Nobody
On Tue, 04 Jun 2013 00:58:42 -0700, Νικόλαος Κούρας wrote: > Τη Τρίτη, 4 Ιουνίου 2013 10:39:08 π.μ. UTC+3, ο > χρήστης Nobody έγραψε: > >> Chrome didn't choose ISO-8859-1, the server did; the HTTP response says: >> Content-Type: text/html;charset=ISO-8859-1 >

Re: how to detect the character encoding in a web page ?

2013-06-05 Thread Nobody
On Thu, 06 Jun 2013 03:55:11 +1000, Chris Angelico wrote: > The HTTP header is completely out of band. This is the best way to > transmit encoding information. Otherwise, you assume 7-bit ASCII and start > parsing. Once you find a meta tag, you stop parsing and go back to the > top, decoding in th

Re: Python Game Development?

2013-06-08 Thread Nobody
On Fri, 07 Jun 2013 08:53:03 -0700, letsplaysforu wrote: > I was planning on making a small 2D game in Python. Are there any > libraries for this? I know of: [snip] There's also Pyglet. -- http://mail.python.org/mailman/listinfo/python-list

Re: A few questiosn about encoding

2013-06-09 Thread Nobody
On Sun, 09 Jun 2013 03:44:57 -0700, Νικόλαος Κούρας wrote: >>> Since 1 byte can hold up to 256 chars, why not utf-8 use 1-byte for >>> values up to 256? > >>Because then how do you tell when you need one byte, and when you need >>two? If you read two bytes, and see 0x4C 0xFA, does that mean tw

RE: Popen and reading stdout in windows

2013-06-11 Thread Nobody
On Tue, 11 Jun 2013 01:50:07 +, Joseph L. Casale wrote: > I am using Popen to run the exe with communicate() and I have sent stdout > to PIPE without luck. Just not sure what is the proper way to iterate over > the stdout as it eventually makes its way from the buffer. The proper way is:

Re: A few questiosn about encoding

2013-06-12 Thread Nobody
On Wed, 12 Jun 2013 14:23:49 +0300, Νικόλαος Κούρας wrote: > So, how many bytes does UTF-8 stored for codepoints > 127 ? U+..U+007F 1 byte U+0080..U+07FF 2 bytes U+0800..U+ 3 bytes >=U+1 4 bytes So, 1 byte for ASCII, 2 bytes for other Latin characters, Greek, Cyrillic, Arabi

Re: A few questiosn about encoding

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 12:01:55 +1000, Chris Angelico wrote: > On Thu, Jun 13, 2013 at 11:40 AM, Steven D'Aprano > wrote: >> The *mechanism* of UTF-8 can go up to 6 bytes (or even 7 perhaps?), but >> that's not UTF-8, that's UTF-8-plus-extra-codepoints. > > And a proper UTF-8 decoder will reject "\

Re: "Don't rebind built-in names*" - it confuses readers

2013-06-13 Thread Nobody
On Thu, 13 Jun 2013 01:23:27 +, Steven D'Aprano wrote: > Python does have a globally-global namespace. It is called "builtins", and > you're not supposed to touch it. Of course, being Python, you can if you > want, but if you do, you are responsible for whatever toes you shoot off. > > Modify

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 18:16:05 +0300, Nick the Gr33k wrote: > My question is why the expr (name and month and year) result in the > value of the last variable whic is variable year? For much the same reason that an OR expression returns the first true value. "or" and "and" only evaluate as many a

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 19:30:27 +, Grant Edwards wrote: > 2. Returning one the objects that result from the evaluation of the > operands instead of returning True or False. > > This is what seems to be confusing him. This is much less common > than short-circuit evaluation. FWIW,

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Fri, 14 Jun 2013 16:49:11 +, Steven D'Aprano wrote: > Unlike Javascript though, Python's idea of truthy and falsey is actually > quite consistent: Beyond that, if a user-defined type implements a __nonzero__() method then it determines whether an instance is true or false. If it implement

Re: Eval of expr with 'or' and 'and' within

2013-06-14 Thread Nobody
On Sat, 15 Jun 2013 03:56:28 +1000, Chris Angelico wrote: > With a few random oddities: > bool(float("nan")) > True > > I somehow expected NaN to be false. Maybe that's just my expectations > that are wrong, though. In general, you should expect the behaviour of NaN to be the opposite of w

Re: Popen in Python3

2013-06-19 Thread Nobody
On Wed, 19 Jun 2013 23:03:05 +, Joseph L. Casale wrote: > I am trying to invoke a binary that requires dll's in two places all of > which are included in the path env variable in windows. When running this > binary with popen it can not find either, passing env=os.environ to open > made no dif

Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte

2013-07-04 Thread Nobody
On Thu, 04 Jul 2013 13:38:09 +0300, Νίκος wrote: > So you are also suggesting that what gesthostbyaddr() returns is not > utf-8 encoded too? The gethostbyaddr() OS function returns a byte string with no specified encoding. Python 3 will doubtless try to decode that to a character string using so

Re: Concurrent writes to the same file

2013-07-11 Thread Nobody
On Wed, 10 Jul 2013 22:57:09 -0600, Jason Friedman wrote: > Other than using a database, what are my options for allowing two processes > to edit the same file at the same time? When I say same time, I can accept > delays. What do you mean by "edit"? Overwriting bytes and appending bytes are sim

Re: How do I get the OS System Font Directory(Cross-Platform) in python?

2013-07-11 Thread Nobody
On Thu, 11 Jul 2013 08:32:34 -0700, Metallicow wrote: > How do I get the OS System Font Directory(Cross-Platform) in python? What makes you think the system *has* a system font directory? In the traditional X11 model, the only program which needs fonts is the X server, and that can be configured

Re: Simple Python script as SMTP server for outgoing e-mails?

2013-07-22 Thread Nobody
On Mon, 22 Jul 2013 14:19:57 +0200, Gilles wrote: > Incidently, how do ISP MTAs find whether the remote MTA is legit or > running on some regular user's computer? Look up the IP address in a database. If they don't have a database, perform a reverse DNS lookup and reject anything which looks like

Re: Beginner. 2d rotation gives unexpected results.

2013-07-23 Thread Nobody
On Tue, 23 Jul 2013 15:11:43 +0200, Peter Otten wrote: > The conversion to int introduces a rounding error that accumulates over > time. Most floating point calculations introduce a rounding error. If the calculations are iterated, the error will accumulate. In general, you want to avoid accumu

Re: how to interact with Windows cmd?

2012-07-05 Thread Nobody
On Wed, 04 Jul 2012 20:10:47 -0700, self.python wrote: > 2. after this, I typed like "cd .." but I/O is already closed so I > can't do another things.. Don't use .communicate() if you want to keep the child process alive. Write to p.stdin and read p.stdout and p.stderr. In general, you'll need t

Re: How to safely maintain a status file

2012-07-09 Thread Nobody
On Sun, 08 Jul 2012 22:57:56 +0200, Laszlo Nagy wrote: > Yes, this is much better. Almost perfect. Don't forget to consult your > system documentation, and check if the rename operation is atomic or not. > (Most probably it will only be atomic if the original and the renamed file > are on the same

Re: How to print stdout before writing stdin using subprocess module in Python?

2012-07-23 Thread Nobody
On Mon, 23 Jul 2012 06:01:23 -0700, Sarbjit singh wrote: > proc = subprocess.Popen("cp -i a.txt b.txt", shell=True, > stdin=subprocess.PIPE, stdout=subprocess.PIPE, > stderr=subprocess.STDOUT,) > stdout_val, stderr_val = proc.communicate() > print stdout_val b.txt? > > proc.communicate("y") >

Re: Calling Values

2012-08-03 Thread Nobody
On Fri, 03 Aug 2012 04:49:46 -0700, Subhabrata wrote: > I am trying to call the values of one function in the another function > in the following way: > def func1(): > num1=10 > num2=20 > print "The Second Number is:",num2 > return > > def func2(): > num3=num1+num2 >

Re: Deciding inheritance at instantiation?

2012-08-03 Thread Nobody
On Fri, 03 Aug 2012 13:48:08 -0700, Tobiah wrote: > I have a bunch of classes from another library (the html helpers > from web2py). There are certain methods that I'd like to add to > every one of them. So I'd like to put those methods in a class, > and pass the parent at the time of instantiat

Re: Pickle file and send via socket

2012-08-06 Thread Nobody
On Mon, 06 Aug 2012 06:32:13 -0700, S.B wrote: > Does anyone know if it's possible to pickle and un-pickle a file across > a network socket. i.e: First host pickles a file object and writes the > pickled file object to a client socket. Second host reads the pickled > file object from the server so

Re: looking for a neat solution to a nested loop problem

2012-08-06 Thread Nobody
On Mon, 06 Aug 2012 17:52:31 +0200, Tom P wrote: > consider a nested loop algorithm - > > for i in range(100): > for j in range(100): > do_something(i,j) > > Now, suppose I don't want to use i = 0 and j = 0 as initial values, but > some other values i = N and j = M, and I want to

Re: looking for a neat solution to a nested loop problem

2012-08-07 Thread Nobody
On Mon, 06 Aug 2012 21:02:33 -0700, Larry Hudson wrote: >> for i in range(N,N+100): >> for j in range(M,M+100): >> do_something(i % 100 ,j % 100) >> >> Emile > > How about... > > for i in range(100): > for j in range(100): > do_something((i + N) % 100,

Re: Why doesn't Python remember the initial directory?

2012-08-19 Thread Nobody
On Sun, 19 Aug 2012 14:01:15 -0700, Giacomo Alzetta wrote: > You can obtain the working directory with os.getcwd(). Maybe. On Unix, it's possible that the current directory no longer has a pathname. As with files, directories can be "deleted" (i.e. unlinked) even while they're still in use. Simi

Re: "convert" string to bytes without changing data (encoding)

2012-08-29 Thread Nobody
On Wed, 29 Aug 2012 19:39:15 -0400, Piet van Oostrum wrote: >> Reading from stdin/a file gets you bytes, and not a string, because >> Python cannot automagically guess what format the input is in. >> > Huh? Oh, it can certainly guess (in the absence of any other information, it uses the current l

Re: Moving folders with content

2012-09-15 Thread Nobody
On Sat, 15 Sep 2012 04:36:00 +, jyoung79 wrote: > I am working in both OS X Snow Leopard and Lion (10.6.8 and 10.7.4). > I'm simply wanting to move folders (with their content) from various > servers to the hard drive and then back to different directories on the > servers. > > I want to

Re: Moving folders with content

2012-09-16 Thread Nobody
On Sun, 16 Sep 2012 12:40:18 +0200, Hans Mulder wrote: > But you should get into the habit of using shell=False whenever > possible, because it is much easier to get it right. More accurately, you should get into the habit of passing a list as the first argument, rather than a string. On Unix-li

Re: portable way of locating an executable (like which)

2012-09-20 Thread Nobody
On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: > I'd like to implement the equivalent functionality of the unix command > /usr/bin/which > > The function should work under Linux and under windows. Note that "which" attempts to emulate the behaviour of execvp() etc. The exec(3) manpage wil

Re: Exact integer-valued floats

2012-09-21 Thread Nobody
On Fri, 21 Sep 2012 17:29:13 +, Steven D'Aprano wrote: > The question is, what is the largest integer number N such that every > whole number between -N and N inclusive can be represented as a float? > > If my tests are correct, that value is 9007199254740992.0 = 2**53. > > Have I got this r

Re: Exact integer-valued floats

2012-09-22 Thread Nobody
On Fri, 21 Sep 2012 15:23:41 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Have I got this right? Is there a way to work out the gap between one >> float and the next? > > Yes, 53-bit mantissa as people have mentioned. That tells you what ints > can be exactly represented. But, arithme

Re: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change'

2012-09-28 Thread Nobody
On Fri, 28 Sep 2012 06:12:35 -0700, 陈伟 wrote: > what is the difference between st_ctime and st_mtime one is the time of > last change and the other is the time of last modification, but i can > not understand what is the difference between 'change' and 'modification'. st_mtime is updated when th

Re: what is the difference between st_ctime and st_mtime one is the time of last change and the other is the time of last modification, but i can not understand what is the difference between 'change'

2012-09-29 Thread Nobody
On Fri, 28 Sep 2012 11:48:23 -0600, Kristen J. Webb wrote: > NOTE: I am a C programmer and new to python, so can anyone comment > on what the st_ctime value is when os.stat() is called on Windows? The documentation[1] says: st_ctime - platform dependent; time of most recent metadata change o

Re: Insert item before each element of a list

2012-10-08 Thread Nobody
On Mon, 08 Oct 2012 12:28:43 -0700, mooremathewl wrote: import itertools x = [1, 2, 3] y = list(itertools.chain.from_iterable(('insertme', x[i]) for i in range(len(x y > ['insertme', 1, 'insertme', 2, 'insertme', 3] >>> [i for j in [1,2,3] for i in ('insertme', j)]

Re: Checking for dlls in ctypes

2012-10-13 Thread Nobody
On Fri, 12 Oct 2012 12:28:17 -0400, Dave Angel wrote: > Using bare excepts is almost never a good idea. If it "works" you get no > clues what went wrong. For example, a typo in source code can trigger a > bare exception, as can a user typing Ctrl-C. So when you're using bare > excepts, you hav

Re: overriding equals operation

2012-10-16 Thread Nobody
On Tue, 16 Oct 2012 08:51:46 -0500, Pradipto Banerjee wrote: > I am trying to define class, where if I use a statement a = b, then > instead of "a" pointing to the same instance as "b", it should point to a > copy of "b", but I can't get it right. It cannot be done. Name binding ("variable = val

Re: Watching output and put back in background

2012-10-19 Thread Nobody
On Thu, 18 Oct 2012 14:05:58 +0100, andrea crotti wrote: > Maybe a solution would be to redirect the stderr to file and watch that > instead.. > > Or otherwise I could use a thread for each shell command, but I would like > to avoid head-aches with possible race-conditions.. If you're running mu

Re: locking files on Linux

2012-10-19 Thread Nobody
On Thu, 18 Oct 2012 14:44:27 +0100, andrea crotti wrote: > Uhh I see thanks, I guess I'll use the good-old .lock file (even if it > might have some problems too). In which case, you don't see. A lock file is also advisory, i.e. it only affects applications which explicitly check for a lock file.

Re: Preserving unicode filename encoding

2012-10-20 Thread Nobody
On Sat, 20 Oct 2012 13:43:16 -0700, Julien Phalip wrote: > I've noticed that the encoding of non-ascii filenames can be inconsistent > between platforms when using the built-in open() function to create files. > > For example, on a Ubuntu 10.04.4 LTS box, the character u'ş' (u'\u015f') > gets enc

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: > Containment of nan in collection is tested by is, not ==. AFAICT, it isn't specific to NaN. The test used by .index() and "in" appears to be equivalent to: def equal(a, b): return a is b or a == b IOW, it always checks

Re: a.index(float('nan')) fails

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 08:56:16 +0200, Thomas Rachel wrote: > Am 27.10.2012 06:48 schrieb Dennis Lee Bieber: > >> I don't know about the more modern calculators, but at least up >> through my HP-41CX, HP calculators didn't do (binary) "floating >> point"... They did a form of BCD with a fixed n

Re: ctypes free memory which is allocated in C DLL

2012-10-27 Thread Nobody
On Sat, 27 Oct 2012 07:42:01 -0700, zlchen.ken wrote: > I have a DLL which written in C language, one of the function is to > allocate a structure, fill the members and then return the pointer of > the structure. > > After Python called this function, and done with the returned structure, > I wo

Re: Avoiding defunct processes

2012-11-02 Thread Nobody
On Thu, 01 Nov 2012 19:16:17 -0700, Richard wrote: > I create child processes with subprocess.Popen(). > Then I either wait for them to finish or kill them. > Either way these processes end up as defunct until the parent process > completes: > $ ps e > 6851 pts/5Z+ 1:29 [python] You need

Re: Subprocess puzzle and two questions

2012-11-15 Thread Nobody
On Wed, 14 Nov 2012 20:49:19 -0500, Roy Smith wrote: >> I'm slightly surprised that there's no way with the Python stdlib to >> point a DNS query at a specific server > > Me too, including the "only slightly" part. The normal high-level C > resolver routines (getaddrinfo/getnameinfo, or even t

Re: Subprocess puzzle and two questions

2012-11-16 Thread Nobody
On Thu, 15 Nov 2012 20:07:38 -0500, Roy Smith wrote: >>> gethostbyname() and getaddrinfo() use the NSS (name-service switch) >> mechanism, which is configured via /etc/nsswitch.conf. Depending upon >> configuration, hostnames can be looked up via a plain text file >> (/etc/hosts), Berkeley DB file

Re: latin1 and cp1252 inconsistent?

2012-11-16 Thread Nobody
On Fri, 16 Nov 2012 13:44:03 -0800, buck wrote: > When a user agent [browser] would otherwise use a character encoding given > in the first column [ISO-8859-1, aka latin1] of the following table to > either convert content to Unicode characters or convert Unicode characters > to bytes, it must ins

Re: latin1 and cp1252 inconsistent?

2012-11-17 Thread Nobody
On Sat, 17 Nov 2012 08:56:46 -0800, buck wrote: >> Given that the only differences between the two are for code points >> which are in the C1 range (0x80-0x9F), which should never occur in HTML, >> parsing ISO-8859-1 as Windows-1252 should be harmless. > > "should" is a wish. The reality is that

Re: Getting a seeded value from a list

2012-11-20 Thread Nobody
On Mon, 19 Nov 2012 21:45:55 -0800, frednotbob wrote: > What I'm trying to do is set a persistent state for the levels generated > by make_map(), so the player can move between floors without generating a > totally new randomized floor each time. You need to distinguish between immutable data (e.

Re: Encoding conundrum

2012-11-21 Thread Nobody
On Wed, 21 Nov 2012 03:24:01 -0800, danielk wrote: >> >>> import sys >> >>> sys.stdout.encoding >> 'cp437' > > Hmmm. So THAT'S why I am only able to use 'cp437'. I had (mistakenly) > thought that I could just indicate whatever encoding I wanted, as long as > the codec supported it. sys.stdout.enc

Re: How to pass class instance to a method?

2012-11-26 Thread Nobody
On Sun, 25 Nov 2012 04:11:29 -0800, ALeX inSide wrote: > How to "statically type" an instance of class that I pass to a method of > other instance? Python isn't statically typed. You can explicitly check for a specific type with e.g.: if not isinstance(arg, SomeType): raise T

Re: os.popen and the subprocess module

2012-11-29 Thread Nobody
On Thu, 29 Nov 2012 10:09:44 +0100, Thomas Rachel wrote: > The variant with shell=True is more os.popen()-like, but has security > flaws (e.g., what happens if there are spaces or, even worse, ";"s in the > command string? I think that you're conflating the shell= option with whether the command

Re: Imaging libraries in active development?

2012-11-29 Thread Nobody
On Wed, 28 Nov 2012 04:30:25 -0800, Alasdair McAndrew wrote: > What I want to know is - what are the current "standard" libraries for > image processing in Python which are in active development? NumPy/SciPy. PIL is fine for loading/saving image files (although if you're using a GUI toolkit, tha

Re: forking and avoiding zombies!

2012-12-12 Thread Nobody
On Tue, 11 Dec 2012 13:25:36 +, andrea crotti wrote: > But actually why do I need to move away from the current directory of the > parent process? It's not required, it's just "best practice". Often, the current directory is simply whichever directory it happened to inherit from the shell wh

Re: pygame - importing GL - very bad...

2013-01-01 Thread Nobody
On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote: > In [11]: del format > --- > NameError Traceback (most recent call last) > in () > > 1 del format > > NameError: name 'format' is not de

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Nobody
On Thu, 17 Jan 2013 07:02:24 -0800, Utpal Sarkar wrote: > I was assuming that sys.stdout would be referencing the same physical > stream as iostreams::cout running in the same process, but this doesn't > seem to be the case. At startup, it refers to the same FILE* as C's stdout. This initially sh

Re: Windows subprocess.call problem

2013-01-21 Thread Nobody
On Mon, 21 Jan 2013 07:25:06 -0400, Tom Borkin wrote: > It opens the first song and hangs on subsequent songs. It doesn't open the > next song or execute the print until I have closed the first one. I want it > to open all in the list, one after another, so I have all those songs > available. Plea

Inherent asyncore.dispatcher_with_send exception

2013-01-24 Thread nobody
Hi, I have a class ClientHandler(asyncore.dispatcher_with_send), it was running fine without calling any of my own classes. But it got following exception when I called my own class GetMyResponse inside the def handle_read(self). Not sure why it causes disturbance to asyncore.dispatcher_with_se

sockobj.connect Errno 13 Permission denied

2013-01-26 Thread nobody
Hi, I have a client program Client.py which has a statement of sockobj.connect(), the port number 6 is used, so no problem from port permission. I am puzzled because I can run Client.py from command line in my user account or apache user account without any problems. But if I run it from

Re: question about function pointer

2012-02-17 Thread Nobody
On Fri, 17 Feb 2012 16:53:00 +0900, Zheng Li wrote: > def method1(a = None): > print a > > i can call it by > method1(*(), **{'a' : 1}) > > I am just curious why it works and how it works? > and what do *() and **{'a' : 1} mean? In a function call, an argument consisting of * followed by

Re: Generating class definitions at runtime in memory from XSD or JSON

2012-02-17 Thread Nobody
On Thu, 16 Feb 2012 17:15:59 -0800, Stodge wrote: > Does anyone know of a library to generate class definitions in memory, > at runtime, from XSD or JSON? I know about PyXB, generateDS and some > others, but they all rely on generating python source files at the > command line, and then using thos

Re: question about file handling with "with"

2012-03-29 Thread Nobody
On Wed, 28 Mar 2012 11:31:21 +0200, Jabba Laci wrote: > Is the following function correct? Is the input file closed in order? > > def read_data_file(self): > with open(self.data_file) as f: > return json.loads(f.read()) Yes. The whole point of being able to use a file as a context m

Re: simple rsa from javascript to python

2012-04-02 Thread Nobody
On Mon, 02 Apr 2012 16:19:05 -0700, Astan Chee wrote: > and I'm trying to convert this into python and I'm rather stuck with > pycrypto as there is no example on how to make the public key with a mod > and exponent (or I've probably missed it). from Crypto.PublicKey import RSA mod = long("B99808B

Re: No os.copy()? Why not?

2012-04-04 Thread Nobody
On Wed, 04 Apr 2012 08:14:18 -0400, Roy Smith wrote: >> And sparse files are really hard to reproduce, at least on Unix: on >> Linux even the system's cp doesn't guarantee sparseness of the copy (the >> manual mentions a "crude heuristic"). > > I imagine the heuristic is to look for blocks of all

Re: Reading Live Output from a Subprocess

2012-04-06 Thread Nobody
On Thu, 05 Apr 2012 23:57:49 -0700, bunslow wrote: > Okay, I've been trying for days to figure this out, posting on forums, > Googling, whatever. I have yet to find a solution that has worked for me. > (I'm using Python 3.2.2, Ubuntu 11.04.) Everything I've tried has led to > buffered output being

Re: escaping/encoding/formatting in python

2012-04-06 Thread Nobody
On Thu, 05 Apr 2012 22:28:19 -0700, rusi wrote: > All this mess would vanish if the string-literal-starter and ender > were different. You still need an escape character in order to be able to embed an unbalanced end character. Tcl and PostScript use mirrored string delimiters (braces for Tcl, p

Re: escaping/encoding/formatting in python

2012-04-06 Thread Nobody
On Fri, 06 Apr 2012 06:22:13 -0700, rusi wrote: > But are not such cases rare? They exist, therefore they have to be supported somehow. > For example code such as: > print '"' > print str(something) > print '"' > > could better be written as > print '"%s"' % str(something) Not if the text betw

Re: Reading Live Output from a Subprocess

2012-04-06 Thread Nobody
On Fri, 06 Apr 2012 12:21:51 -0700, Dubslow wrote: > It's just a short test script written in python, so I have no idea how > to even control the buffering In Python, you can set the buffering when opening a file via the third argument to the open() function, but you can't change a stream's buffe

Re: Pass a list of variables to a procedure

2012-04-07 Thread Nobody
On Sat, 07 Apr 2012 14:15:09 -0700, KRB wrote: > I would like to be able to pass a list of variables to a procedure, and > have the output assigned to them. Use a dictionary or an object. If the variables are globals (i.e. attributes of the current module), you can pass the result of globals() i

Re: f python?

2012-04-08 Thread Nobody
On Sun, 08 Apr 2012 04:11:20 -0700, Xah Lee wrote: > Ok no problem. My sloppiness. After all, my implementation wasn't > portable. So, let's fix it. After a while, discovered there's the > os.sep. Ok, replace "/" to os.sep, done. Then, bang, all hell > went lose. Because, the backslash is used as

Re: can I overload operators like "=>", "->" or something like that?

2012-04-20 Thread Nobody
On Thu, 19 Apr 2012 12:28:50 -0700, dmitrey wrote: > can I somehow overload operators like "=>", "->" or something like that? > (I'm searching for appropriate overload for logical implication "if a then > b") You cannot create new operators, but you can control how existing operators work on type

Re: why () is () and [] is [] work in other way?

2012-04-25 Thread Nobody
On Mon, 23 Apr 2012 10:01:24 -0700, Paul Rubin wrote: >> I can't think of a single case where 'is' is ill-defined. > > If I can't predict the output of > > print (20+30 is 30+20) # check whether addition is commutative print > (20*30 is 30*20) # check whether multiplication is commutat

Re: why () is () and [] is [] work in other way?

2012-04-26 Thread Nobody
On Thu, 26 Apr 2012 11:31:39 -0700, John Nagle wrote: > I would suggest that "is" raise ValueError for the ambiguous cases. > If both operands are immutable, "is" should raise ValueError. That's the > case where the internal representation of immutables shows through. This breaks one of the m

Re: ctype C library call always returns 0 with Python3

2012-05-19 Thread Nobody
On Sat, 19 May 2012 11:30:46 +0200, Johannes Bauer wrote: > import ctypes > libc = ctypes.cdll.LoadLibrary("/lib64/libc-2.14.1.so") > print(libc.strchr("abcdef", ord("d"))) In 3.x, a string will be passed as a wchar_t*, not a char*. IOW, the memory pointed to by the first argument to strchr() wil

Re: Help doing it the "python way"

2012-05-26 Thread Nobody
On Thu, 24 May 2012 13:22:43 -0700, Scott Siegler wrote: > is there a way to do something like: > [(x,y-1), (x,y+1) for zzz in coord_list] > or something along those lines? [(xx,yy) for x, y in coord_list for xx, yy in [(x,y-1),(x,y+1)]] or: [(x,yy) for x, y in coord_list for yy i

Re: Smallest/cheapest possible Python platform?

2012-05-26 Thread Nobody
On Sat, 26 May 2012 11:34:19 -0400, Roy Smith wrote: > The Rasberry Pi certainly looks attractive, but isn't quite available > today. Can you run Python on an Arduino? Things like > http://www.embeddedarm.com/products/board-detail.php?product=TS-7250 are > more than I need, and the $129 price pr

Re: Compare 2 times

2012-06-06 Thread Nobody
On Wed, 06 Jun 2012 05:50:02 -0700, loial wrote: > I have a requirement to test the creation time of a file with the current > time and raise a message if the file is more than 15 minutes old. > > Platform is Unix. > > I have looked at using os.path.getctime for the file creation time and > tim

Re: float("nan") in set or as key

2011-06-02 Thread Nobody
On Thu, 02 Jun 2011 09:54:30 +, Steven D'Aprano wrote: >> Exceptions allow you to write more natural code by ignoring the awkward >> cases. E.g. writing "x * y + z" rather than first determining whether "x >> * y" is even defined then using a conditional. > > You've quoted me out of context.

Re: Something is rotten in Denmark...

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 11:43:54 +1200, Gregory Ewing wrote: >> But going against generally accepted semantics should at least >> be clearly indicated. Lambda is one of the oldest computing abstraction, >> and they are at the core of any functional programming language. > > Yes, and Python's lambdas

Re: how to avoid leading white spaces

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 04:30:46 +, Chris Torek wrote: >>I'm not sure what you mean by "full 16-bit Unicode string"? Isn't >>unicode inherently 32 bit? > > Well, not exactly. As I understand it, Python is normally built > with a 16-bit "unicode character" type though It's normally 32-bit on p

Re: how to avoid leading white spaces

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 02:58:24 +, Chris Torek wrote: > Python might be penalized by its use of Unicode here, since a > Boyer-Moore table for a full 16-bit Unicode string would need > 65536 entries (one per possible ord() value). However, if the > string being sought is all single-byte values, a

Re: float("nan") in set or as key

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 14:52:39 +, Grant Edwards wrote: >> It's arguable that NaN itself simply shouldn't exist in Python; if >> the FPU ever generates a NaN, Python should raise an exception at >> that point. > > Sorry, I just don't "get" that argument. I depend on compliance with > IEEE-754,

Re: except KeyError, everywhere

2011-06-03 Thread Nobody
On Fri, 03 Jun 2011 22:08:16 +0200, Wilbert Berendsen wrote: > I find myself all over the place associating objects with each other using > dicts as caches: > Are there other peoply using things like this? Is there a solution like > this in the standard lib that I'm overlooking? The general con

Re: float("nan") in set or as key

2011-06-04 Thread Nobody
On Sat, 04 Jun 2011 00:52:17 -0700, rusi wrote: >> If you're "fluent" in IEEE-754, then you won't find its behaviour >> unexpected. OTOH, if you are approach the issue without preconceptions, >> you're likely to notice that you effectively have one exception mechanism >> for floating-point and ano

Re: how to avoid leading white spaces

2011-06-04 Thread Nobody
On Sat, 04 Jun 2011 13:41:33 +1200, Gregory Ewing wrote: >> Python might be penalized by its use of Unicode here, since a >> Boyer-Moore table for a full 16-bit Unicode string would need >> 65536 entries > > But is there any need for the Boyer-Moore algorithm to > operate on characters? > > Seem

Re: how to avoid leading white spaces

2011-06-04 Thread Nobody
On Sat, 04 Jun 2011 05:14:56 +, Steven D'Aprano wrote: > This fails to support non-ASCII letters, and you know quite well that > having to spell out by hand regexes in both upper and lower (or mixed) > case is not support for case-insensitive matching. That's why Python's re > has a case in

Re: float("nan") in set or as key

2011-06-05 Thread Nobody
On Sun, 05 Jun 2011 07:21:10 +, Steven D'Aprano wrote: > Returning a sentinel meaning "an exceptional event occurred" is hardly > unusual, even in Python. str.find() does is, as does re.search() and > re.match(). These are not "exceptional" conditions; if they were, an exception would be us

Re: float("nan") in set or as key

2011-06-06 Thread Nobody
On Mon, 06 Jun 2011 00:55:18 +, Steven D'Aprano wrote: > And thus we come back full circle. Hundreds of words, and I'm still no > closer to understanding why you think that "NAN == NAN" should be an > error. Well, you could try improving your reading comprehension. Counselling might help.

Re: Validating string for FDQN

2011-06-06 Thread Nobody
On Mon, 06 Jun 2011 17:40:29 -0700, Eric wrote: > Is there a library or regex that can determine if a string is a fqdn > (fully qualified domain name)? I'm writing a script that needs to add > a defined domain to the end of a hostname if it isn't already a fqdn > and doesn't contain the defined do

  1   2   3   4   5   6   7   8   >