[EMAIL PROTECTED] wrote:
> Hi. How can I determin the hwaddr or ipaddress of the networkinterface
> that is used in an outgoing connection?
Is sock_object.getsockname() enough?
http://docs.python.org/lib/socket-objects.html
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-lis
halex2000 wrote:
> Hi all, I'm new with Python, and I thought to use it to automatically rename
> some files in a directory, but I don't know where should I search the
> functions: to get all the files of a directory, to rename the files and so
> on.
Python programmers are constantly looking at
Christoph Zwerschke wrote:
> In Python, it is possible to multiply a string with a number:
>
> >>> "hello"*3
> 'hellohellohello'
Which is really useful.
> However, you can't multiply a string with another string:
>
> >>> 'hello'*'world'
> Traceback (most recent call last):
> File "", line 1
Christoph Zwerschke wrote:
[...]
> That may be the main problem to decide whether the cartesian product
> should return a generator or a list.
The Cartesion product is a set.
[...]
> That's the other problem. The uses cases (like the password cracker
> example) are very limited and in these cas
Steven D'Aprano wrote:
> Bryan Olson wrote:
>>Christoph Zwerschke wrote:
>>[...]
>>
>>>That may be the main problem to decide whether the cartesian product
>>>should return a generator or a list.
>>
>>The Cartesion product is a set.
>
Steven D'Aprano wrote:
> Bryan Olson wrote:
>
>
[Christoph Zwerschke had written:]
>>>What I expect as the result is the "cartesian product" of the strings.
>>
>>There's no such thing; you'd have to define it first. Are duplicates
>>s
Steven D'Aprano wrote:
> On Mon, 23 Jan 2006 18:17:08 +0000, Bryan Olson wrote:
>
>
>>Steven D'Aprano wrote:
>>
>>>Bryan Olson wrote:
>>>
>>[Christoph Zwerschke had written:]
>>
>>>>>What I expect as the result is the &q
Kay Schluehr wrote:
> Bryan Olson wrote:
>
>
>>There's no such thing; you'd have to define it first. Are duplicates
>>significant? Order?
>
>
> That's all trivial isn't it? A string is a set of pairs (i,c) where i
> is an integer number, t
Bryan Olson wrote:
> Duncan Booth wrote:
>
>> Here's the way I would do it:
>>
>>>>> def occurrences(it):
>>
>>
>> res = {}
>> for item in it:
>> if item in res:
>> res[item] += 1
>>
Christoph Zwerschke wrote:
> Bryan Olson schrieb:
>
>>> Still think there is no such thing?
>>
>>
>> Uh, yes.
>>
>>The Cartesian product of two sets A and B (also called the
>>product set, set direct product, or cross product) is defi
le dahut wrote:
> I have a server that receives data from a client, detect the end of this
> data and send other data back to the client (it's to measure bandwidth).
> I think the best way is to thread a part of the server's program am I
> right ?
Others disagree on this, but in most cases, yes:
Christoph Zwerschke wrote:
> Bryan Olson wrote:
>
>> The claim "everything is a set" falls into the category of
>> 'not even wrong'.
>
> No, it falls into the category of the most fundamental Mathematical
> concepts. You actually *define* tuples a
le dahut wrote:
> I've read the Gordon McMillan's "Socket Programming HOWTO"
Just a few days ago, another participant in this group noted
that code in Gordon McMillan's "Socket Programming HOWTO"
does not work. He was right. The code is wrong.
Currently, one can Google up "Python socket howto",
Tuvas wrote:
> The stuff that it runs aren't heavily processor intensive, but rather
> consistant. It's looking to read incoming data. For some reason when it
> does this, it won't execute other threads until it's done. Hmmm.
> Perhaps I'll just have to work on a custom read function that doesn't
>
Peter Hansen wrote:
> Ivan Voras wrote:
>> Python is bad for concurrently executing/computing threads, but it
>> shouldn't be that bad - do you have lots of compute-intensive threads?
>
> Just in case anyone coming along in the future reads this statement, for
> the record I'd like to say this i
Tuvas wrote:
> The read function used actually is from a library in C, for use over a
> CAN interface. The same library appears to work perfectly find over C.
[...]
> When nothing is happening, the thread runs pretty consistantly at 1
> second. However, when it is doing IO through this C function o
Lee Leahu wrote:
> I am trying to write a simple threaded application which will
> simulate 1000 connections to a remote service in order to
> stress test" that the remote service can handle that many
> connections.
That shouldn't be a problem on a modern OS, but there are
still quite a few not
Fredrik Lundh wrote:
> Steven D'Aprano wrote:
[...]
>>del L[:] works, but unless you are Dutch, it fails the
>>obviousness test.
>
>
> unless you read some documentation, that is. del on sequences
> and mappings is a pretty fundamental part of Python. so are slicings.
So is consistency; it ain
Alan Morgan wrote:
> slogging_away wrote:
>
>>Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310
>>32 bit (Intel)] on win32, and have a script that makes numerous checks
>>on text files, (configuration files), so discrepancies can be reported.
>>The script works fine but it app
Fredrik Lundh wrote:
> Bryan Olson wrote:
>
>
>>So is consistency; it ain't Perl, thank Guido.
>
> consistency is the hobgoblin of little minds.
Look up that saying. Any clues?
>>Python now has, what, three built-in mutable collections types:
>>lists,
Terry Reedy wrote:
> "Bryan Olson" wrote:
>
>>I made a script with 100,000 if's, (code below) and it appears
>>to work on a couple systems, including Python 2.4.2 on Win32-XP.
>>So at first cut, it doesn't seem to be just the if-count that
>>tri
Magnus Lycka wrote:
> Ed Singleton wrote:
>
>> The point is that having to use del to clear a list appears to the
>> inexperienced as being an odd shaped brick when they've already used
>> the .clear() brick in other places.
>
>
> Agreed. The smart way to go from this stage of surprise is
> not
Rene Pijlman wrote:
> Carl J. Van Arsdall:
>
>>I've been toying with threads a lot lately and I've noticed that if a
>>scripting error occurs in a thread the thread dies, but not the process
>>that spawned the thread.
>>
>>Is python supposed to behave this way or is this type of behavior
>>acci
Magnus Lycka wrote:
> Bryan Olson wrote:
>
>> The original question was about idioms and understanding, but
>> there's more to the case for list.clear. Python is "duck typed".
>> Consistency is the key to polymorphism: type X will work as an
>> actua
Magnus Lycka wrote:
> Bryan Olson wrote:
>
>> Magnus Lycka wrote:
>>
>>> Do you really have a usecase for this? It seems to me that your
>>> argument is pretty hollow.
>>
>>
>> Sure:
>>
>> if item_triggering_end in colle
Raymond Hettinger wrote:
[...]
> If you're asking why list's don't have a clear() method, the answer is
> that they already had two ways to do it (slice assignment and slice
> deletion) and Guido must have valued API compactness over collection
> polymorphism.
That's a decision from long ago. Now
Magnus Lycka wrote:
> Bryan Olson wrote:
>
>> Magnus Lycka wrote:
>>
>>> Bryan Olson wrote:
>>>
>>>> big_union = set()
>>>> for collection in some_iter:
>>>> big_union.update(t)
>>>> colle
Farshid Lashkari wrote:
> When I pass an empty string to a function is a new string object created
> or does python use some global pre-created object? I know python does
> this with integer objects under a certain value. For instance, in the
> following code is a new string object created for e
[EMAIL PROTECTED] wrote:
> thread1:
> while 1:
> buf = s.read()
> process(buf)
>
> thread2:
> while 1:
> buf = getdata()
> s.write(buf)
Sockets don't have read() and write() methods. Connected
sockets have recv() and send()/sendall(). Python's socket
module
Carl J. Van Arsdall wrote:
> Steve Horsley wrote:
>
>> [EMAIL PROTECTED] wrote:
>>
>>
>>> thread1:
>>> while 1:
>>> buf = s.read()
>>> process(buf)
>>>
>>> thread2:
>>> while 1:
>>> buf = getdata()
>>> s.write(buf)
>>
>>
>> It is safe, but watch out fo
rtilley wrote:
> Carsten Haese wrote:
>
>> Is there a reason why os.environ['SYSTEMDRIVE'] shouldn't work?
>
> I didn't know it was in os! It returns C: instead of C:\ like my method.
> Other than that, it seems to do the trick.
To get it with the \, you might use:
os.path.abspath(os.envi
Dan Stromberg wrote:
> I've been putting a little bit of time into a file indexing engine
[...]
> So far, I've been taking the approach of using a single-table database
> like gdbm or dbhash [...] and making each entry keyed by
> a word, and under the word in the database is a null terminated list
Atanas Banov wrote:
> Bryan Olson wrote:
>
>>To get it with the \, you might use:
>>
>> os.path.abspath(os.environ['SYSTEMDRIVE'])
>
>
> wrong!
> the result is incorrect if the current directory is different from the
> root.
Oops, sorry. I
Dan Stromberg wrote:
> Bryan Olson wrote:
[...]
>> Well, you could use simple files instead of fancy database tables.
>
> That's an interesting thought. Perhaps especially if australopithecine
> were saved in a filename like:
>
> ~/indices/au/st/ra/lo/pi/th/ec/in
Dan Stromberg wrote:
> I've been putting a little bit of time into a file indexing engine
[...]
To solve the O.P.'s first problem, the facility we need is an
efficient externally-stored multimap. A multimap is like a map,
except that each key is associated with a collection of values,
not just a s
Paul Probert wrote:
[...]
> Its happening roughly 4 times a day total on our 20 machines, ie about
> once every 5 days on a given machine.
Do they all have similar anti-virus programs? Some of those can
freeze out other tasks from time to time. Just one more candidate.
--
--Bryan
--
http://ma
Diez B. Roggisch wrote:
>> Use a separate thread for downloading.
>
> Or the twisted select-reactor. No threads needed.
He's using urllib2, which does not use Twisted's select-reactor.
Fortunately urllib2 downloads run fine in their own threads; no
rewrite-all-the-code-as-Twisted-state-machines
John Coleman wrote:
>I have a rough classification of languages into 2 classes: Zen
> languages and tool languages. A tool language is a language that is,
> well, a *tool* for programming a computer. C is the prototypical tool
> language. Most languages in the Algol family are tool languages. V
Tuvas wrote:
> Okay, I don't know if your farmiliar with the miller-rabin primality
> test,
Paul is familiar with it. When he referred to your Miller-Rabin
test, he meant all the rounds.
> but it's what's called a probabalistic test. Meaning that trying
> it out once can give fake results.
In t
Tuvas wrote:
[...]
> Actually, I did another test, and realized that it was indeed a bug in
> the code. Yikes. Oh well, thanks for the help in identifying it!
>
> An example that would be alot easier is this:
>
Mod(16,561).is_strong_pseudo_prime()
>
> True
Hmmm...my M-R tester disagrees...
Frank Millman wrote:
[...]
> There is a server component and a client component. All the business
> logic is performed on the server.
Oh, what a give-away. If the logic is in the server, then the
client component should probably be the user's chosen web browser.
> The client communicates with
Tuvas wrote:
> Okay, I'm working on devoloping a simple, cryptographically secure
> number, from a range of numbers (As one might do for finding large
> numbers, to test if they are prime). My function looks like this:
>
> def cran_rand(min,max):
> if(min>max):
> x=max
> max=mi
Tuvas wrote:
> Okay, now I get the correct number of 561 pseudoprimes, 5, so I can
> assume that it is indeed working right.
Your code now looks right, so I'm guessing "5" was a typo,
perhaps because "5" is just below "8" on the numeric keypad.
You can simplify your loop like:
def is_strong_pse
Peter Hansen wrote:
> The archives could tell you more, but basically on is usually interested
> in *identity* with a singleton object (None), not in whether the object
> on is examining happens to compare equal. A custom object could be
> designed to compare equal to None in certain cases, eve
Paul Rubin wrote:
> My favorite way to convert strings to numbers is with binascii:
>
> from binascii import hexlify
> def s2num(text):
>return int(hexlify(text), 16)
Neat. I use the empty string as a binary representation of zero,
which you can accommodate with:
def s2num(text):
ret
Justin T. wrote:
> True, but Python seems to be the *best* place to tackle this problem,
> at least to me. It has a large pool of developers, a large standard
> library, it's evolving, and it's a language I like :). Languages that
> seamlessly support multi-threaded programming are coming, as are
>
Oğuz Yarımtepe wrote:
> As i read pickle module is Python-spesific. I need to talk with a Java
> application and get the infortion that it will send. What i do right now is
> listening a socket and reding the string that is sent by the java
> application. So the java application is sending a str
Andy wrote:
> I'm going to develop a software package that includes a web server
> (and PHP code) , a database, and some Python code of course. I am
> being strongly suggested to make it to work on a dual- or multi-core
> computer, but I'm confused on how to take advantage of the multiple
> CPUs.
Grant Edwards wrote:
[...]
> import socket,random
>
> HOST = '' # Symbolic name meaning the local host
> PORT = 8765 # Arbitrary non-privileged port
> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> s.connect((HOST, PORT))
Actually the empty string passed for
Steve Holden wrote:
[...]
> If I can blow my own trumpet briefly, two customers (each using over 25
> kLOC I have delivered over the years) ran for two years while I was away
> in the UK without having to make a single support call. One of the
> systems was actually locked in a cupboard all that
Tim Daneliuk wrote:
> Grzegorz Słodkowicz wrote:
[...]
>> You're mixing definition with application. You didn't say a word about
>> what complex numbers are, not a word about the imaginary unit, where
>
> I was trying to motivate the idea by means of analogy. This is a
> legitimate thing to do.
herman wrote:
> In my python program, I would to like to spwan 5 threads, for the them
> for 5 minutes maximum and the continue. Here is my script:
>
> threads = []
>
> for j in range(5):
> t = MyThread()
> threads.append(t)
>
>
The expression "faint praise" comes to mind.
--
--Bryan
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rudin wrote:
> Dr writes:
>> I would like to create a pretty big list of lists; a list 3,000,000
>> long, each entry containing 5 empty lists. My application will append
>> data each of the 5 sublists, so they will be of varying lengths (so no
>> arrays!).
>>
>> Does anyone know the most effic
Paul Rubin wrote:
> Lawrence D'Oliveiro writes:
>> Except that the NSA's reputation has taken a dent since they failed to
>> anticipate the attacks on MD5 and SHA-1.
>
> NSA had nothing to do with MD5, and it's to NSA's credit that SHA-1
> held up for as long as it did.
I haven't kept up. Has any
Arnau Sanchez wrote:
>> Dotan Cohen wrote:
>>> Second, in Turbo C -111%10=-1 however in python -111%10=9. Is one or
>>> the other in error? Is this a known gotcha? I tried to google the
>>> subject however one cannot google the symbol %. Thanks in advance.
[...]
> In fact, what you get in C depend
Dotan Cohen wrote:
> On 10/09/2007, Bryan Olson <[EMAIL PROTECTED]> wrote:
>> Not according to the C standard:
>>
>> When integers are divided, the result of the / operator is
>> the algebraic quotient with any fractional part discarded.(87)
>>
Dotan Cohen wrote:
> FIrst of all, how is the % symbol (as in 70%6=4) called in English?
The operator is usually called "mod". (The symbol is usually
called "percent".)
I reserve "modulo" for its usage in mathematics. 70 modulo 6
is an equivalence class containing infinitely many integers.
In mat
Dennis Lee Bieber wrote:
> The best answer is probably to be found from the definition of
> divmod()
The divmod() function is one of those little delights that reminds
me why I love Python, but I do not think it answers the question
here. The definition of divmod() references the '%' operati
Scott David Daniels wrote:
> C, which was designed as a "high level assembly language," does not
> tightly define the results of / and % for negative numbers. Instead
> it defines the result for positive over positive, and constrains the
> result for the others.
Not true. Here it is again:
sturlamolden wrote:
[...]
> If you want to utilize the computing power of multiple CPUs, you
> should use multiple processes instead of threads. On Python this is
> mandatory due to the GIL. In any other language it it highly
> recommended. The de-factor standard for parallel multiprocessing (MPI)
Steve Holden wrote:
> Hendrik van Rooyen wrote:
>> Are sockets full duplex?
>>
> Yes. But you have to use non-blocking calls in your application to use
> them as full-duplex in your code.
Hmmm... I'm missing something. Suppose I have one thread (or
process) reading from a blocking-mode socket whi
Prateek wrote:
[...]
> Mainly it revolves around dedicating one core for executing
> synchronized code and doing context switches instead of acquiring/
> releasing locks.
>
> http://www.brainwavelive.com/blog/index.php?/archives/12-Suggestion-for-removing-the-Python-Global-Interpreter-Lock.html
C
Amer Neely wrote:
> This seems to indicate that maybe my host needs to configure Apache to
> run python scripts? But I didn't need to do anything with mine.
Another possibility: If it works on Windows but not Unix, check
the end-of-line characters. Windows ends each line with the two
character se
J. Cliff Dyer wrote:
> Bryan Olson wrote:
>> Scott David Daniels wrote:
>>
>>> C, which was designed as a "high level assembly language," does not
>>> tightly define the results of / and % for negative numbers. Instead
>>> it defines the r
Amer Neely wrote:
> I don't have shell access but I can run 'which python' from a Perl
> script, and I will try the different shebang line you suggested.
And after trying it, Amer Neely reported:
> I tried `which python` and `whereis python` and got 0 back as a result.
> So it seems Python is n
Jim Langston wrote:
> Assignment operators in C++ should attempt to prevent two pointers poining
> to the same memory location. Consier a simple class (untested):
>
> class Foo
> {
> public:
>char* Data;
>int DataSize;
>Foo( int Size ): DataSize( Size ) { Data = new char[Size]; }
>
Rustom Mody asked:
> [...] why does
>
> (yield(x) for x in si(l) if x % p != 0)
>
> not work? I would have expected generator expression to play better
> with generators.
You have a statement, "yield(x)", where the construct requires
an expression.
--
--Bryan
--
http://mail.python.org/mailma
Karthik Gurusamy wrote:
> While it's easy to explain the behavior, I think the decision to dis-
> allow mutable items as keys is a bit arbitrary.
Furthermore, it's not really true.
class Blurf (object):
def __init__(self, intval):
self.seti(intval)
def seti(se
TheFlyingDutchman asked of someone:
> Would you know what technique the custom web server uses
> to invoke a C++ app
No, I expect he would not know that. I can tell you
that GWS is just for Google, and anyone else is almost
certainly better off with Apache.
> (ditto for Java and Python) CGI is s
Gabriel Genellina wrote:
> En Thu, 20 Sep 2007 08:46:29 -0300, Steven D'Aprano
>
>> Another way is to use this class:
>>
>> class HashableList(list):
>> def __hash__(self):
>> return hash(tuple(self))
>
> ...and that will stop working as soon as the list is mutated (which is
> exact
Carl Banks wrote:
> Not many people are bit-fiddling these days. One of the main uses of bit
> fields is flags, but that's not often done in Python because of keyword
> arguments and dicts, which are lot more versatile. Another major use,
> talking to hardware, is not something oft done in Pyt
Sean Tierney wrote:
>>From Twisted's website "Twisted is a networking engine written in
> Python, supporting numerous protocols. It contains a web server,
> numerous chat clients, chat servers, mail servers, and more.
>
> Given that Zope is also a written in python, supports numerous
> protocols,
[EMAIL PROTECTED] wrote:
> There are already anonymous functions in Python.
>
> lambda x, y, z: x + y + z
>
> is the same as:
>
> def _(x, y, z): return x + y + z
They are the same only in special cases:
The special identifier "_" is used in the interactive
interpreter to store the r
Cristian wrote:
> [...] Specifically, he's having trouble
> thinking of functions as first order data (don't worry, I haven't
> confused him with such terminology yet).
[...]
> And, after we finally
> get a hold of first order functions, we appreciate its incorporation
> into languages. It would b
Paul Rubin wrote:
> Bryan Olson <[EMAIL PROTECTED]> writes:
>> [EMAIL PROTECTED] wrote:
>>> There are already anonymous functions in Python.
>>> lambda x, y, z: x + y + z
>>> is the same as:
>>> def _(x, y, z): return x + y + z
>> The
[EMAIL PROTECTED] wrote:
> Bryan Olson wrote:
>> One surprising result was that more of the Python
>> programmers surveyed use bitwise operators than are aware
>> of the exponentiation operator, which C does not offer.
>
> On that subject, I'd suggest
coldpizza wrote:
> I want to run a database query and then display the first 10 records
> on a web page. Then I want to be able to click the 'Next' link on the
> page to show the next 10 records, and so on.
> My question is how to implement paging, i.e. the 'Next/Prev' NN
> records without reestab
Alex Martelli wrote:
> Bryan Olson wrote:
[...]
>> How does Google use Python? As their scripting-language
>> of choice. A fine choice, but just a tiny little piece.
>>
>> Maybe Alex will disagree with me. In my short time at
>> Google, I was uber-nobody.
&
Alex Martelli wrote:
> Bryan Olson <[EMAIL PROTECTED]> wrote:
>...
>>> YouTube (one of Google's most valuable properties) is essentially
>>> all-Python (except for open-source infrastructure components such as
>>> lighttpd). Also, at Google
Paul Rubin wrote:
> You can also pass the open sockets around between processes instead of
> reverse proxying, using the SCM_RIGHTS message on Unix domain sockets
> under Linux, or some similar mechanism under other Unixes (no idea
> about Windows). Python does not currently support this but one o
coldpizza wrote:
> It turned out that the method above ('SELECT * FROM TABLE LIMIT L1,
> L2') works ok both with mysql and sqlite3, therefore I have decided to
> stick with it until I find something better. With Sqlite3 you are
> supposed to use LIMIT 10 OFFSET NN, but it also apparently supports
>
Lawrence D'Oliveiro wrote:
> In Bryan Olson wrote:
>
>> coldpizza wrote:
>>> It turned out that the method above ('SELECT * FROM TABLE LIMIT L1,
>>> L2') works ok both with mysql and sqlite3, therefore I have decided to
>>> stick with
Lawrence D'Oliveiro wrote:
> Bryan Olson wrote:
>
>> Lawrence D'Oliveiro wrote:
>>> In Bryan Olson wrote:
>>>
>>>> coldpizza wrote:
>>>>> It turned out that the method above ('SELECT * FROM TABLE LIMIT L1,
>>>>
Mark Summerfield wrote:
> The sorteddict API that has emerged so far is (1) apart from the
> constructor, everything is identical to dict, (2) the constructor
> takes the same args as sorted(), so if you want to seed with a dict or
> with keywords you write sorteddict(dict(a=1,b=2), ...), (or you c
Hendrik van Rooyen wrote:
> "Nick Craig-Wood" wrote: [about passing sockets between processes]
>> It is trivial to pass a socket to a new thread or a forked child - you
>> don't need this mechanism for that. It doesn't work on different
>> machines though - it has to be on the same machine.
>
>
[EMAIL PROTECTED] wrote:
> Hello everyone,
>
> OK, so I want to split a string c into words using several different
> separators from a list (dels).
>
> I can do this the following C-like way:
>
> c=' abcde abc cba fdsa bcd '.split()
> dels='ce '
> for j in dels:
> cp=[]
> for i i
Summercool wrote:
> I wonder which language allows you to change an argument's value?
> like:
>
> foo(&a) {
> a = 3
> }
>
> n = 1
> print n
>
> foo(n) # passing in n, not &n
> print n
>
> and now n will be 3. I think C++ and PHP can let you do that, using
> their reference (alias) mechan
Hendrik van Rooyen wrote:
> "Jeff Pang" wrote:
>> I want to transmit an array via socket from a host to another.
>> How to do it? thank you.
>
> pickle it and send it and unpickle it on the other side.
>
> See the cPickle module docs for loads and dumps.
In particular note:
Warning: The p
[david] wrote:
> If I have 37 threads, all calling a large function 'f', are the formal
> parameters thread safe?
>
> That is, will the formal parameters be trashed? Do you need to use
> locks or semaphores before using formal parameters? Are the labels for
> formal parameters static?
>
> If I
rodmc wrote:
> Probably a silly question but I am writing a CGI script which need to
> check the referring URL, can anyone provide any pointers? I have
> looked at URLLib2 and a couple of other libraries, but am slightly
> confused.
When you say, "check the referring URL," what are checking about
Grant Edwards wrote:
> It may be obvious that he has a question. It's not the least
> bit obvious what that question is.
How can we efficiently implement an abstract data type, call it
'DoubleDict', where the state of a DoubleDict is a binary
relation, that is, a set of pairs (x, y); and the ope
Mark Dickinson wrote:
> Jeff Goldfin wrote:
>> I can pack and unpack a float into a long
>> e.g.
>> struct.unpack('I',struct.pack('f',0.123))[0]
>> but then I'm not sure how to work with the resulting long.
>>
>> Any suggestions?
>
> One alternative to using struct is to use math.ldexp and math.fr
rodmc wrote:
[...]
> Python:
>
> f = open("finish.html")
> doc = f.read()
> f.close()
> print doc
You might need to start with:
print "Content-Type: text/html"
print
Is "finish.html" in the right place? When you browse to your
script, can you see that you're getti
[EMAIL PROTECTED] wrote:
> Bryan Olson wrote:
>> How can we efficiently implement an abstract data type, call it
>> 'DoubleDict', where the state of a DoubleDict is a binary
>> relation, that is, a set of pairs (x, y); and the operations on
>> a Doubl
rodmc wrote:
> [...] I have played around a bit more
> so that both the image and HTML file are in the public_html folder.
> They are called via python using a relative URL, and have permissions
> set to 755. Within the HTML file the image is accessed using just
> "banner.jpg". The actual page disp
Lie wrote:
[...]
> Soft Exception is an exception that if is unhandled, pass silently as
> if nothing happened.
[...]
> Implementation:
> Simple implementation might be done by catching all exceptions at the
> highest level, then filtering which exceptions would be stopped (Soft
> Exception) and w
k.i.n.g. wrote:
> I think I am not clear with my question, I am sorry. Here goes the
> exact requirement.
>
> We use dd command in Linux to create a file with of required size. In
> similar way, on windows I would like to use python to take the size of
> the file( 50MB, 1GB ) as input from user an
Benjamin Watine wrote:
> And if somebody need it : to get the stdout in a var (myNewVar), not in
> the shell :
>
> cat = subprocess.Popen('cat', shell = True, stdin = subprocess.PIPE,
> stdout=subprocess.PIPE)
> cat.stdin.write(myVar)
> cat.stdin.close()
> cat.wait()
> myNewVar = cat.stdout.read
I wrote:
> [...] Pipe loops are tricky business.
>
> Popular solutions are to make either the input or output stream
> a disk file, or to create another thread (or process) to be an
> active reader or writer.
Or asynchronous I/O. On Unix-like systems, you can select() on
the underlying file descr
201 - 300 of 371 matches
Mail list logo