.. couldn't you
use python itself or parts of it as a library?
I know you said you're not looking to interface C++ with Python in any
way, but why emulate if you could include? (Again, if this is stupid,
sorry! :) )
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
:
cond ( - 1 , 1 , f ) * ( ( float ( e ) * ( 2 ** 4 ) ) + ( float ( d ) *
8 ) + ( float ( c ) * 4 ) + ( float ( b ) * 2 ) + float ( a ) )
Once you've got that far the rest should be easy. :)
Peace,
~Simon
http://pyparsing.wikispaces.com/
http://pages.cpsc.ucalgary.ca/~aycock/spark/
http
Jason Jiang wrote:
Hi,
I have two modules: a.py and b.py. In a.py, I have a function called
aFunc(). I'm calling aFunc() from b.py (of course I import module a first).
The question is how to directly set a breakpoint in aFunc().
The way I'm doing now is to set a breakpoint in b.py at the
Jason Jiang wrote:
Simon Forman [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Jason Jiang wrote:
Hi,
I have two modules: a.py and b.py. In a.py, I have a function called
aFunc(). I'm calling aFunc() from b.py (of course I import module a
first).
The question is how
| sys.maxint
2147483647
From the sys module docs:
maxint
The largest positive integer supported by Python's regular integer
type. This is at least 2**31-1. The largest negative integer is
-maxint-1 -- the asymmetry results from the use of 2's complement
binary arithmetic.
Peace,
~Simon
P.S. ints
/lib/module-tabnanny.html
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Also, check out:
http://groups.google.ca/group/comp.lang.python/browse_frm/thread/712572b3c2f2cb13
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Jason Jiang wrote:
Great! It's working now. Thank you so much.
Jason
You're welcome, it's a pleasure! :-D
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
lists):
def rev(n):
i = iter(n)
while True:
a = i.next()
yield i.next()
yield a
Example of use:
r = range(24)
print list(rev(r))
If your list comes from binary (str) data, and you're dealing with
endianness, I smell a faster way using struct.
Peace,
~Simon
Or you can use the has_key() and test it first. For example
if foo.has_key('bar'):
print 'we have it'
else :
print 'we don't have bar.'
Nowadays you can also say:
if 'bar' in foo:
# do something
--
http://mail.python.org/mailman/listinfo/python-list
while loop.
HTH,
~Simon
P.S. Take a look at the random.shuffle() function... :-)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Hello.
I'm writing a proxy class, i.e: a class whose methods mostly delegate
their functionality to other class object. Most of the methods (which
are quite a lot) defined in the class would end up being:
def thisIsTheMethodName(self):
is not being executed
interactively. It will simply get the value of sys.argv and then
throw it away. Try import sys; print sys.argv, if you want to print
the value of sys.argv.
Happy coding,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
(fname)
6) Why are you using #~ for comments?
Also, check out os.path.splitext()
http://docs.python.org/lib/module-os.path.html#l2h-1761
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
be appreciated
Yes.
Please read this: http://www.catb.org/~esr/faqs/smart-questions.html
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
Ok, I know it's been asked a million times, but I have a more specific
question so hopefully this won't be just the same old post. I've tried a
few different editors, and I really like UltraEdit, but it's
Windows-only and I'm working more on Linux nowadays.
Here are my
Paul Rubin wrote:
Simon Forman [EMAIL PROTECTED] writes:
Have you tried IDLE? It ships with python, meets your 5 criteria(*),
can be customized (highlighting colors and command keys and more), and
includes a usable GUI debugger. It's got some warts, but I like it a
lot, it's pretty much
a number to a given precision in decimal digits (default 0
digits).
This always returns a floating point number. Precision may be
negative.
HTH,
~Simon
BTW, '+value+' ..? Huh?
--
http://mail.python.org/mailman/listinfo/python-list
. YMMV
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
you're trying to do and post its output.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Sybren Stuvel wrote:
Dan Bishop enlightened us with:
a = b = 1e1000 / 1e1000
a is b
True
a == b
False
If a is b then they refer to the same object, hence a == b. It
cannot be otherwise, unless Python starts to defy logic. I copied your
code and got the expected result:
a = b =
Alexandre Guimond wrote:
thx for all the help simon. good ideas i can work with.
thx again.
alex.
You're very welcome, a pleasure. ;-)
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
Simon Forman wrote:
| class f:
... def __init__(self):
... del self
Of course nothing happens. Args are local variables. 'self' is is a
vanilla arg of a vanilla function.
I know.
...
| e = f()
| e
__main__.f instance at 0xb7dd91ec
The following list of functions are also defined as methods of string
and Unicode objects; see ``String Methods'' (section 2.3.6) for more
information on those.
i.e. string.lower() = WHAT?.lower() (would return what?...)
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
your object is by choosing which
class to use to construct the object.
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
', -1L), (3L, 'Test2', -1L))
-j
k.description
See also http://www.python.org/dev/peps/pep-0249/
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
On 16 Aug 2006 12:53:12 -0700, KraftDiner [EMAIL PROTECTED] wrote:
I can see that this might work...
c = [a, b]
for c in [a,b]:
c.getName()
but when does baseClass ever get used?
Why did i even have to define it?
Well, quite.
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http
the bill?
http://docs.python.org/lib/module-email.Utils.html#l2h-3944
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
/comp.lang.python/browse_frm/thread/b4e08adec2d835f5/af340f17faec4055
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
?
Anyway, I don't know much about them, other than that they are
slightly unusual objects that play a very restricted role in python,
rather like the Ellipsis.
Workarounds are possible, I think, but really you almost certainly
don't need to do this.
Peace,
~Simon
--
http://mail.python.org
going to 3D and 4D grid, and its somewhat annoying
to carry so many indices in my class definition.
Simon Forman wrote:
Alexandre Guimond wrote:
Hi all,
i'm trying to deepcopy a slice object but i get the following error.
Does anyone know a workaround?
ActivePython 2.4.3
Duncan Booth wrote:
Simon Forman wrote:
Why would you want to [deep]copy a slice object?
I would guess the original poster actually wanted to copy a data structure
which includes a slice object somewhere within it. That is a perfectly
reasonable albeit somewhat unusual thing to want
cga2000 wrote:
On Tue, Aug 08, 2006 at 12:22:42PM EDT, Simon Forman wrote:
John Salerno wrote:
[EMAIL PROTECTED] wrote:
John Aside from the normal commands you can use, I was wondering if
John it's possible to use Python from the terminal instead of the
John normal
[EMAIL PROTECTED] wrote:
| would use a recursive approach for this - given that you have a sort
of recursive datastructure:
py def SetNewDataParam2(Data, NewData):
... if type(Data[Data.keys()[0]]) == type(dict()):
Note:
| type(dict()) is dict
True
dict *is* a type...
--
= f_factory(True)
| foo
__main__.f instance at 0xb7dd944c
| foo = f_factory(False)
| foo
| print foo
None
There might be a way using __new__(), but I don't know what or how.
Also, del is a statement, not a function. You don't need to use
()'s.
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo
Kairo Matthias wrote:
How can i encode with yEnc?
What's yEnc? :-)
Seriously though, did you try googling for yEnc python?
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
replacing stdout) was rewriting it not to use print
statements...
http://groups.google.ca/group/comp.lang.python/browse_frm/thread/70aca5068c18384f/d19e9119b7ca1af2
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
the lines with '\n' and stick a call to rstrip()
in there:
G = grouper(5, R, '')
print '\n'.join(' '.join(str(n) for n in N) for N in G).rstrip()
but then you're back to ugly. lol.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
,
John
Very nice.
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
write most of my tiny
little helper scripts in python, but in this case, bash is the clear
winnar. (And on *nix. man pages are your best friend. Plus you get to
feel all l33t when you grok them. lol)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
John Salerno wrote:
Simon Forman wrote:
It's simple, short, and to-the-point. The equivalent python script
would be much longer, for no appreciable gain. I write most of my tiny
little helper scripts in python, but in this case, bash is the clear
winnar. (And on *nix. man pages
:
new_list = [0 for notused in xrange(100)]
or if you already have a list:
my_list.extend(0 for notused in xrange(100))
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
AndrewTK wrote:
Simon Forman wrote:
So I'm guessing it's something wrong in your java server.
Thanks then. I'll keep testing then... Although I don't seem to have
netcat on my unit...
I'm using a uni computer so I can't install stuff... but I'm guessing
what I wrote is something like
/howto/unicode , there is a brief
section near the bottom on Unicode filenames. If your problem is
related to Unicode, this may help you, but I'm not sure.
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
combination and you
should be well rewarded. :-)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
for you then it won't do any harm to use it. (Just
don't mention my name ;-) )
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
://docs.python.org/lib/module-subprocess.html)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
.
(If you're using IDLE it should have indented it for you when you hit
return after the def statement.)
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
alf wrote:
Simon Forman wrote:
| I = ([n] for n in i)
This is nice but I am iterating thru hude objects (like MBs) so you know ...
No, I don't know... :-)
potentially my source lists are huge - so wanted to avoid unnecessary
memory allocation
My friend, I think you've
]:~ $ python delme.py
'hi there\n'
'how are you\n'
I'm fine thanks\n
[EMAIL PROTECTED]:~ $
So I'm guessing it's something wrong in your java server.
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
/Cookbook/Python/Recipe/81330 It uses
a regular expression, so I'd guess it wouldn't be to hard to get it to
work in multiline mode.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
this? Usually you would just say obj =
pickle.load(f) and be done with it (you could manipulate obj after it's
created, of course.) Why do you want to do obj = Obj() but have the
obj come from obj.dat?
Just curious.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Simon Forman wrote:
f pemberton wrote:
Marc 'BlackJack' Rintsch wrote:
In [EMAIL PROTECTED], f pemberton
wrote:
I've tried using replace but its not working for me.
xdata.replace('abcdef', 'highway')
xdata.replace('defgef', 'news')
xdata.replace('effwer', 'monitor
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 8
model name : Pentium III (Coppermine)
HTH, ;-)
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
)
| I.next()
[0]
| I.next()
[1]
| I.next()
[2]
| I.next()
Traceback (most recent call last):
File stdin, line 1, in ?
StopIteration
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
alf wrote:
Simon Forman wrote:
class LW(object): # ListWrapper
... def __init__(self, i):
... self.theiter = i
... def next(self):
... return [self.theiter.next()]
I hoped one lamda would take care of it but looks like it is a simplest
choice.
| I = ([n] for n
be useful or appropriate?
Simon Hibbs
--
http://mail.python.org/mailman/listinfo/python-list
', 'Power Macintosh', 'powerpc')
That's on Mac OS X 10.4.6. Indeed more useful.
Michiel
It might be a good idea to write a brief script to print out
sys.platform, platform.platform(), platform.uname(), etc.. and post it
here for people to run and post their results.
Peace,
~Simon
--
http
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
on.
(BTW, while len(data) 0: can just be while data:)
(Heaven help me, but maybe you could post your java server code here...
If anyone screams too loudly blame me. Hahaha..)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
is going on.
I need your help. Thanks a lot.
Have you tried http://wiki.wxpython.org/index.cgi/Asking_For_Help
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
in s.get_matching_blocks() if n == c]
[3]
There may be better ways.
my real problem involves figuring out how to reduce the number of hits to
the db/tbl...
What?
thanks
ps. if this is confusing, i could provide psuedo-code to make it easier to
see...
Yes, please.
Peace,
~Simon
--
http://mail.python.org
cPickle.dumps(hicon) leads to nothing, cause it only gets the ID of the
hicon :(
Any ideas / recommendations / tipps?
Harald
Write the data to a temporary file and load it from there.
(Also, iconPathName is already a string, you don't have to call
str(iconPathName).)
HTH,
~Simon
--
http
John Salerno wrote:
Simon Forman wrote:
What about the version I gave you 8 days ago? ;-)
http://groups.google.ca/group/comp.lang.python/msg/a80fcd8932b0733a
It's clean, does the job, and doesn't have any extra nesting.
Peace,
~Simon
I remember that version, but I found
] functions, or redesign it somehow.
Peace,
~Simon
(Also, there's no such thing as sys.error, do you mean
sys.excepthook()?)
--
http://mail.python.org/mailman/listinfo/python-list
Slawomir Nowaczyk wrote:
On Thu, 10 Aug 2006 11:39:41 -0700
f pemberton [EMAIL PROTECTED] wrote:
# I have kind of an interesting string, it looks like a couple hundred
# letters bunched together with no spaces. Anyway, i'm trying to put a
# ? and a (\n) newline after every 100th character
service
is a good one.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
to create programmed objects that received a budget of processor
time. The objects would not work if they ran out of processor
time...
Perhaps something like this could help you? (Sorry to be so vague.)
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
about the version I gave you 8 days ago? ;-)
http://groups.google.ca/group/comp.lang.python/msg/a80fcd8932b0733a
It's clean, does the job, and doesn't have any extra nesting.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
://groups.google.ca/group/comp.lang.python/browse_frm/thread/8e427c5e6da35c/a34397ba74892b4e
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
godavemon wrote:
I'm using python's struct and binascii modules to write some values
from my parser to binary floats. This works great for all of my binary
files except one. For some reason this file is saving to 836 (stated
by my command shell) bytes instead of 832 like it should. It
an
'!' before them. If you ever need to run something that for some
reason doesn't work with this, you can always run !bash and do it in
bash. :-)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
) in the string to the var variable at each
iteration.
HTH,
~Simon
(BTW, ur is your and u is you. I'm sorry to nitpick, but it's
a personal idiosyncrasy of mine to be bothered by such.)
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Simon Forman:
It's unlikely to
be deprecated since it doesn't make much sense to make it an attribute
of the str type.
Why?
Thank you,
bearophile
Let me toss the question back at you: Does it make sense to you that
str should have this attribute? Why?
I'm
ds4ff1z wrote:
Hello, i'm looking to find and replace multiple characters in a text
file (test1). I have a bunch of random numbers and i want to replace
each number with a letter (such as replace a 7 with an f and 6 with a
d). I would like a suggestion on an a way to do this. Thanks
start your script
from a different directory.
HTH.
(Also, if you're not already, be aware of os.path.isfile() and
os.path.isdir(). They should probably be helpful to you.)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
having trouble later I'll try to take another
look at your code. Print statements and debuggers are your friends,
and John Machin's advice seems good to me.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
tuples are all two items, you can do it like this:
y = [(b, a) for a, b in y]
if not, then:
y = [tuple(reversed(t)) for t in y]
:-D
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
.pyc files (when available) of your main module, rather than
re-parsing its text.
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
help system.
object? - Details about 'object'. ?object also works, ?? prints more.
In [1]: !man ls
Reformatting ls(1), please wait...
viewing actual man page here. ~Simon
In [2]: !!ls -l
Out[2]:
['total 40',
'drwxr-xr-x 3 sforman sforman 4096 2006-08-02 12:41 docs',
'drwxr-xr-x 3 sforman sforman
[EMAIL PROTECTED] wrote:
Hi,
there are many ways of solving the problem of finite buffer sizes when
talking to a subprocess. I'd usually suggest using select() but today I
was looking for a more readable/understandable way of doing this. Back
in 1997 Guido himself posted a very nice
Cameron Laird wrote:
In article [EMAIL PROTECTED],
Simon Forman [EMAIL PROTECTED] wrote:
David Bear wrote:
Is there an easy way to get the current level of recursion? I don't mean
.
.
.
import sys
def getStackDepth
library module:
http://docs.python.org/lib/module-email.html
HTH,
~Simon
Out of curiosity, why do you want to _backup_ a gmail account? (I use
my gmail account to backup files and documents I never want to lose.)
I could think of some reasons, but I'm wondering what yours are. : )
--
http
Janto Dreijer wrote:
Janto Dreijer wrote:
John Henry wrote:
Simon Forman wrote:
False not in logflags
Or, if your values aren't already bools
False not in (bool(n) for n in logflags)
Very intriguing use of not in...
Is there a reason why you didn't
to consider would be to split your
download and zipping code into separate functions then create one more
thread to do all the zipping. That way your downloading threads would
never be waiting around for each other to zip.
Just a thought. :)
~Simon
--
http://mail.python.org/mailman/listinfo
python list:
http://www.boost.org/more/mailing_lists.htm
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
.
And if none of those are what you meant by the opposite of an import,
you'll need to be more explicit. ;-)
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list
On 8/3/06, Simon Brunning [EMAIL PROTECTED] wrote:
If you want to remove the module from a namespace into which you
imported it, you can do that with del:
import amodule
amodule.afunction() # Works fine
del amodule
amodule.afunction() # Will die now
Note that this doesn't get rid
, only create a new one.
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list
reference counting *would* remove the
module as soon as you de referenced it, but for the fact that Python
stashes a reference to the module in (IIRC) sys.__modules__. And you
mess with *that* at your peril. ;-)
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http
.
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list
, but it also still has the same value.
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list
newline is not needed since print
will add one of it's own.)
HTH,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
Kkaa wrote:
This seems like the right thing to do, but it runs the program in the
background, and I need my program to wait until the x.exe has finished.
I tried using this code:
p =
subprocess.Popen(x.exe,shell=True,stdout=subprocess.PIPE,stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
in
http://docs.python.org/lib/os-procinfo.html)
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
closest key.
result = u
return result
I hope that helps. :-)
Python is an amazing language once you get the hang of it. Enjoy.
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
://agtk.sourceforge.net/, perhaps? If not, we'll need more context.
--
Cheers,
Simon B,
[EMAIL PROTECTED],
http://www.brunningonline.net/simon/blog/
--
http://mail.python.org/mailman/listinfo/python-list
...'''
if n 4:
return g(n + 1)
else:
return n
Peace,
~Simon
--
http://mail.python.org/mailman/listinfo/python-list
= f.read()
| f.close()
| len(s)
1
| print s
\x00
The problem is not with the read() method. Or, if it is, something
very very weird is going on.
If you can do the above and not get the same results I'd be interested
to know what file data you have, what OS you're using.
Peace,
~Simon
(Think about
1101 - 1200 of 1822 matches
Mail list logo