> >>> 0x & -327681234
>
> 3967286062
Very nice! Thanks for that example. Unsigned long longs:
0x & -9151314442815602945
9295429630893948671L
--
http://mail.python.org/mailman/listinfo/python-list
> Pack it as the actual type, then unpack it as the desired type:
>
> Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
> Type "help", "copyright", "credits" or "license" for more information.>>>
> from struct import pack, unpack
> >>> unpack('=I', pack('=i',-327681234))
>
> (3967286062,)
>
> I wou
In C or C++, I can do this for integer conversion:
unsigned int j = -327681234; // Notice this is signed.
j will equal 3967286062. I thought with Python that I could use struct
to pack the signed int as an unsigned int, but that fails:
>>> x = struct.pack("", line 1, in
struct.error: integer ou
On Dec 16, 9:36 am, Tim Wintle wrote:
> should be:
> def run(t):
> with lock:
> shared_container.append(t.name)
>
> (or lock.acquire() and lock.release() as you mentioned)
Thanks Tim. The with statement is closer to the C++ code (IMO) more so
than the explicit acqu
On Fri, Dec 16, 2011 at 9:24 AM, Brad Tilley wrote:
>
>
> On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote:
>
>> On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote:
>> > 107 void increment_counter( unsigned int& counter )
>> > 108
On Fri, Dec 16, 2011 at 8:33 AM, Tim Wintle wrote:
> On Fri, 2011-12-16 at 05:21 -0800, Brad Tilley wrote:
> > 107 void increment_counter( unsigned int& counter )
> > 108 {
> > 109 boost::mutex::scoped_lock lock( counter_lock );
> >
Hey guys,
I have a C++ function that I'd like to replicate (as closely as
possible) in Python. Here's an example:
107 void increment_counter( unsigned int& counter )
108 {
109 boost::mutex::scoped_lock lock( counter_lock );
110 ++counter;
111
How do I import a module and then ask it to show me its methods or other
aspects about itself during execution? I'd like to do something such as
this:
import win32api
print win32api.methods()
I'd like to write some test scripts that load modules and probe them for
information about themselves
Windows users may find this of interest:
http://filebox.vt.edu/users/rtilley/downloads/automatic_python_install.html
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik Lundh wrote:
Brad Tilley wrote
Just run the built-in Windows utility 'systeminfo' from a cmd prompt.
you're a bit late, aren't you?
for line in data:
if line contains "System Up Time":
print line
what Python version is this?
Sorry, lang mix-up:
x =
Esmail Bonakdarian wrote:
Hi,
Is there a way to display how long a Win XP system has been up?
Somewhat analogous to the *nix uptime command.
Thanks,
Esmail
Just run the built-in Windows utility 'systeminfo' from a cmd prompt.
Python can call 'systeminfo' like this:
import os
uptime = os.popen('sy
Tim Peters wrote:
Not everyone is willing and able to switch to a
new 2.j release as soon as it appears.
The reason I jumped on 2.4 right away was the msi installer for Windows
systems. We can do unattended/automated installs... it's really great...
a killer feature for Windows users who need to
Grant Edwards wrote:
On 2004-12-09, Brad Tilley <[EMAIL PROTECTED]> wrote:
Steven Bethard wrote:
for root, files, dirs in os.walk(path)
for f in files:
try:
x = file(f, 'rb')
data = x.read()
x.close()
Remember that CPython is imple
Steven Bethard wrote:
for root, files, dirs in os.walk(path)
for f in files:
try:
x = file(f, 'rb')
data = x.read()
x.close()
Remember that CPython is implemented in C, and so all the builtin types
(including file) basically execute C code dire
Grant Edwards wrote:
Huh? What do you mean "write a file open"? You want to read a
C source file and execute the C source? If you have access to
a C interpreter, I guess you could invoke the interpreter from
python using popen, and feed the C source to it. Alternatively
you could invoke a compi
Is it possible to write a file open, then read program in C and then
call the C program from a Python script like this:
for root, files, dirs in os.walk(path)
for f in files:
try:
EXECUTE_C_PROGRAM
If possible, how much faster would this be over a pure Python solution?
Tha
Peter Hansen wrote:
Brad Tilley wrote:
What is the proper way to limit the results of division to only a few
spaces after the decimal? I don't need rocket-science like precision.
Here's an example:
1.775 is as exact as I need to be and normally, 1.70 will do.
The answer is "what
Simon Brunning wrote:
On Thu, 09 Dec 2004 09:38:55 -0500, Brad Tilley <[EMAIL PROTECTED]> wrote:
What is the proper way to limit the results of division to only a few
spaces after the decimal? I don't need rocket-science like precision.
Here's an example:
1.775 is as exact as
Hello,
What is the proper way to limit the results of division to only a few
spaces after the decimal? I don't need rocket-science like precision.
Here's an example:
1.775 is as exact as I need to be and normally, 1.70 will do.
Thank you,
Brad
--
http://mail.python.org/mailman/listinfo/python-li
Max M wrote:
Dan Perl wrote:
That was also my impression. Even the description of the problem
looks like it's just copied from the assignment, so probably didn't
even take the time to restate the problem in his own words.
But we're speculating. Either way, this is not a normal request: "I
nee
Darth Haggis wrote:
I need help writing a program
You are to write a python program to accomplish the following:
a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module nam
Grant Edwards wrote:
On 2004-12-03, Max M <[EMAIL PROTECTED]> wrote:
That was also my impression. Even the description of the
problem looks like it's just copied from the assignment, so
probably didn't even take the time to restate the problem in
his own words.
[...]
Hopefully his teacher doesn
Peter Hansen wrote:
... innocent and ignorant users who are concerned about finding
this thing called "Python" on their new machines, and most of
them seem curiously more interested in removing it than in discovering
what it actually is there for.
This has been my experience as well. I don't have m
Martin v. Löwis wrote:
Brad Tilley wrote:
I found the documentation here:
http://python.fyxm.net/2.4/msi.html
The original, of course, is at
http://python.org/2.4/msi.html
Regards,
Martin
Thanks Martin... going to a .msi was a great move... we can do fully
automated, unattended installs now. I
Matt Gerrans wrote:
Anyway, what's to worry about?When the time comes just whip out a little
script that converts Python 1.6 (or whatever you like) to Python3K; it will
only take seven lines of P3K code.
How about 'import classic'
--
http://mail.python.org/mailman/listinfo/python-list
Brad Tilley wrote:
Martin v. Löwis wrote:
Brad Tilley wrote:
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3'
[...]
Python 2.4 does not use this registry entry on the two machines I
have installed it on... a
Martin v. Löwis wrote:
Brad Tilley wrote:
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3'
[...]
Python 2.4 does not use this registry entry on the two machines I have
installed it on... any tips on how to l
Python 2.3 placed a registry key under:
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Python2.3'
When this key was removed, Python no longer appeared in the Windows 'Add
Remove Programs' list. We would remove this registry key to keep users
from uninstalling the software
Brad Tilley wrote:
When memory usage is a concern, is it better to do:
from X import Y
or
import X
Also, is there a way to load and unload modules as they are needed. I
have some scripts that sleep for extended periods during a while loop
and I need to be as memory friendly as possible. I can
Jp Calderone wrote:
On Tue, 30 Nov 2004 10:02:27 -0500, Brad Tilley <[EMAIL PROTECTED]> wrote:
When memory usage is a concern, is it better to do:
from X import Y
or
import X
There is no difference. If you are concerned about memory usage, you
probably need to take a look at th
When memory usage is a concern, is it better to do:
from X import Y
or
import X
Also, is there a way to load and unload modules as they are needed. I
have some scripts that sleep for extended periods during a while loop
and I need to be as memory friendly as possible. I can post a detailed
scrip
31 matches
Mail list logo