On Tue, 2006-04-04 at 21:54 -0400, John Salerno wrote:
> I'm reading Text Processing in Python right now and I came across a
> comment that is helping me to see for loops in a new light. I think
> because I'm used to the C-style for loop where you create a counter
> within the loop declaration,
On Fri, 2006-03-31 at 09:30 +0200, Fredrik Lundh wrote:
> Dennis Lee Bieber wrote:
>
> > > I want to know which is the best IDE for python.Please if
> > > possible mention the features of the IDE.
> >
> > The best IDE is the one that YOU can be most productive in. What /I/
> > find useful ma
On Fri, 2006-03-31 at 12:46 -0800, Karthik Gurusamy wrote:
> Ben Finney wrote:
> > [EMAIL PROTECTED] writes:
> >
> > > I'm fairly new to python. I like to define a big dictionary in two
> > > files and use it my main file, build.py
> > >
> > > I want the definition to go into build_cfg.py and build
ch street he would look
the wrong way, look the correct way and then stare the wrong way again.
Upon noticing my inquisitorial expression, he answered "A good
programmer always looks both ways when crossing a one way street."
I'm uncertain that a quip about abstracting away the rain would
On Mon, 2006-03-27 at 16:15 -0800, [EMAIL PROTECTED] wrote:
> After freezing a PYGTK app, I am unable to run it. It this a common
> problem, because I could not find any documentation on it at all.
>
> I tried freezing this example, which gets by the make as well, but
> running it results in a fa
516455488'
>>>
Works for me. Code snippet? Print does seem to round at 12 digits.
>>> print 1.090516455488E9/100
1090.51645549
>>>
Cheers - Adam DePrince
>
> I know something with float and //...
>
> Anybody?
> How do I get correct number?
--
http://mail.python.org/mailman/listinfo/python-list
;Abc"
>> myfancy_structre.add_somehow( s )
>> t = s[::-1]
>> print s
Abc
>> print t
cbA
Now if strings were mutable:
>> s = "Abc"
>> myfancy_structre.add_somehow( s )
>> s.reverseme()
>> print s
cbA
Other users of s between assignment and reversal (like
myfancy_structure) might not be happy that is was reversed when they
next must use it.
Cheers - Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 2006-03-26 at 16:56 +0200, Matthias Güntert wrote:
> Hello list-members
>
> i am in the process of writing a python script to backup my data. Now I
> would like to implement md5/sha1 hashes.
>
> # do md5 fingerprinting
> if config.get("global", "crc") == "md5":
> m = md
What do you get when you type
md5sum backup.tar.bz2?
- Adam
On Sun, 2006-03-26 at 16:56 +0200, Matthias Güntert wrote:
> Hello list-members
>
> i am in the process of writing a python script to backup my data. Now I
> would like to implement md5/sha1 hashes.
>
> # do md5 fingerprinting
On Sun, 2006-03-26 at 07:21 -0800, Alex Martelli wrote:
> vbgunz <[EMAIL PROTECTED]> wrote:
>
> > I am sorry I couldn't reply sooner! Alex, Python in a nutshell is my
> > bible and I take it virtually everywhere! Seriously, I would highly
> > recommend it to anyone with a little to a lot of Python
The first calls for core language changes, the second calls for a minor
(and likely symbolic) change to list comprehension's semantics to better
support future parallelism.
PEP: XXX
Title: Nondeterminism
Version: $Revision$
Last-Modified: $Date$
Author: Adam DePrince <[EMAIL PROTECTED]&g
On Fri, 2006-03-24 at 10:49 -0800, Robert Hicks wrote:
> How about we all get tatoos? : )
... still trying to scrape the old one off ...
>
> Robert
>
--
http://mail.python.org/mailman/listinfo/python-list
ing its memory of
what it saw in the past.
3. Z_FINISH. This is the default action, this is what is killing you.
Good luck - Adam DePrince
>
> I cannot wait until the end of the stream and then flush, because I need to
> flush after every packet.
>
> Another capability I requ
for me to store
> values inside memory so I can look it up on the next GET request?
Your database really is the best place for that.
Good luck - Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
Droppings from other timing tests; starbucks was kicking me out and I
was in a hurry.
Cheers - Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2006-03-24 at 12:55 +0100, Clemens Hepper wrote:
> Hello,
>
> I've written a little (optimized) method to get a bit-string:
>
> def bitstringneg(number, digits=32):
> """optimized for negative numbers"""
> result = ""
> for a in xrange(digits):
> if number & 1:
> result +=
ut, but your
biggest impediment is how you are looking at the problem.
For reference http://www.python.org/doc/essays/graphs.html
As for detecting neighboors, sure that's easy, but first you have to try
to use a for loop first on your own to tell how many positional items
any two lists differ by.
Cheers and good luck - Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
Excuse me, I mean
python2.4 -mtimeit -s 'from numarray import array; d =
{(100,500):[5,5], (100,501):[6,6],
(100,502):[7,7]}; x = dict(d);' 'for i in x.values():
i[0]*=1;i[1]*=1'
100 loops, best of 3: 1.72 usec per loop
i[0]*=1, not j[0]*=1 ...
--
http://mail.python.org/mailman/listinfo/p
Wait! It occured to me. Why are we touching the key at all. This is
a dictionary with mutable values.
[EMAIL PROTECTED] ~]$ python2.4 -mtimeit -s 'd = {(100,500):[5,5],
(100,501):[6,6],
(100,502):[7,7]}; x = dict(d)' 'for i in x.values():
i[:]=[j*1 for j in i]'
10 loops, best of 3: 2.79 us
Yes, I cede that explicit indexing is faster by quite a bit.
There is a somewhat philosophical decision for why I avoided that. I
prefer to try to present python with as big of a picture of what I want
as possiable. update tells python what I want to do, whereas the
for-loop describes how to. I
This is how python is supposed to work.
I'm sure not what languages you have used ... it seems that you are
expecting some sort rule based system like make, or prolog.
Grab a cup of joe, pull up a chair and let me help you out here.
Python is an imperative language, you can envision the presence
>for key in d:
> d[key] = [x*2 for x in d[key]]
>
Naw, if you are going to use list interpolation go all the way and save
yourself all of that ugly indexing into the dict.
>>> d = {(100,500):[5,5], (100,501):[6,6], (100,502):[7,7]}
>>> d.update( [[key,[x*2 for x in item]] for key,item in d.
. Treat it as you would
such a creature in C ...
vTable[0][0] = 1
or whatever you want to do.
I've seen this question before. Lot in the archives for the subject "2D
array" from Dec 7th 2004 - Dec 10th 2004.
Steven and I recommended roughly opposite solutions at the time :-)
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
ators, reiterables, and other. I think this is
> didactically useful. Spencerators are reiterables.
> Iter(iterator) returning iterator unchanged makes iterator a fixed point of
> iter. It ends any chain of objects returned by repeated iter calls.
> Spencerators prolong any iter chain, making it infinite instead of finite.
> Essential? Repeat the paragraph above with 'a fixed point' substituted for
> 'minimal'.
How is spencerator different than itertools.tee?
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
gt; To do a 2D FFT on a matrix X, you do 1D FFTs on all the rows, producing X',
> then you do 1D FFTs on all the columns of X'.
> So, for a 32x32 2D FFT, you'll end up doing 64 1D FFTs.
FFTW: http://www.fftw.org/
Python bindings for it: http://pylab.sourceforge.net/
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 2005-02-15 at 17:24, Jeff Shannon wrote:
> Ilias Lazaridis wrote:
>
> > Adam DePrince wrote:
> > [...]
> >> You're on it. You drive a car? You have to treat it right to get what
> >> you want, right? Same here. Ask correctly, and y
On Tue, 2005-02-15 at 14:25, Ilias Lazaridis wrote:
> Adam DePrince wrote:
> > On Tue, 2005-02-15 at 13:29, Ilias Lazaridis wrote:
> >>Mike Meyer wrote:
> >>>Ilias Lazaridis <[EMAIL PROTECTED]> writes:
> [...]
> >>MinGW compatibility is not [onl
empts such a feat and possibly
organize unfathomable resources in the attendance of such a lofty goal.
Make us proud Ilias. But whatever you do, don't beg.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
> discussion). Otherwise the debate will go south real quick.
Not only most speed be an issue, but the economics must be such that any
alternative is better than throwing more hardware at the problem.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
e
sure that the data you are reading into your python application was
written by you as a hedge against malicious data. Can I, as a user of
said card, change the data in the pickle? If so, when you load the
pickle back into python you need to confirm that it is a sane pickle
that you wrote earlier.
On Sun, 2005-02-06 at 08:19, Philippe Fremy wrote:
> Adam DePrince wrote:
> > No amount of obfuscation is going to help you.
>
> Theorically, that's true. Anything obfuscated can be broken, just like
> the non obfuscated version. However it takes more skills and time to
file.txt", "w+" )
hash = f.read( sha.digest_size )
mydata = f.read()
if sha.new( mysecret + mydata ).digest() != hash:
raise "Somebody is tring to hack you!"
mydata = cPickle.loads( mydata )
Of course, the security of this scheme is dependent on a lot, including
the strength of sha, your ability to keep your secret key secret, the
correctness of what I'm saying, etc etc etc.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
how good their
implementation of your protocol.
The worst case if you depend on obscurity: The bad guys are rounding
off your pennies as you read this.
The worse case if you depend on encryption and open your spec: You get
to publish your code, but might get competition.
Just my $0.02.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
>>> x = '\x00'
> >>> ord(x)
> 0
> >>> x = '\x15'
> >>> ord(x)
> 21
> >>>
Ethereal's emission of \x00 shouldn't make your life any more
difficult. The conversion of \0xx takes place in the eval. If you
store the string \x00 in a file and call open.read or command.getoutput,
you will get the python string "\\x00". Stuff you read from a file
arrives un-de-escaped.
The solution is simple.
mystring.replace( "\x","0x" )
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
efarious user who
might submit to you:
commands.getoutput( "rm -rf %(HOME)s"%os.environ )
as the "expression" to evaluate.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
saying NP
!= P. Then tell us what you are tring to do; perhaps there is a better
way, perhaps the problem is unsolvable and there is a heuristic that
will satisfy your needs.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
pen so I just have to
> keep read()-ing or maybe is there a type of streaming read? I have many
> cameras, so there are many threads simultaneously reading and dropping them
> in a central Queue for saving later.
>
> I appreciate it!
> -Dave
>
> WebImage = urlli
On Sat, 2005-01-01 at 11:42, Steve Holden wrote:
> Adam DePrince wrote:
> [...]
> >
> > In sort, we must preserve the ability to create an anonymous function
> > simply because we can do so for every other object type, and functions
> > are not special enou
On Fri, 2004-12-31 at 22:09, Terry Reedy wrote:
> "Adam DePrince" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > In sort, we must preserve the ability to create an anonymous function
> > simply because we can do so for every other object type,
On Fri, 2004-12-31 at 17:36, Steven Bethard wrote:
> Adam DePrince wrote:
> > Lets not forget the "real reason" for lambda ... the elegance of
> > orthogonality. Why treat functions differently than any other object?
> >
> > We can operate on every othe
ling list. Take a look at
http://python.org/community/lists.html The news group and this list are
mirrors of each other. Of course, the benefit this provides depends on
which mail client you use.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
e ability to create an anonymous function
simply because we can do so for every other object type, and functions
are not special enough to permit this special case.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote:
> On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote:
> > [snip]
> >
> > Of course, to take advantage of this requires that writev be exposed. I
> > have an implementation of writev.
On Mon, 2004-12-20 at 02:18, Steven Bethard wrote:
> Adam DePrince wrote:
> > file.writelines( seq ) and map( file.write, seq ) are the same; the
> > former is syntactic sugar for the later.
>
> Well, that's not exactly true. For one thing, map(file.write, seq)
> r
On Mon, 2004-12-20 at 00:30, Steven Bethard wrote:
> Adam DePrince wrote:
> > Many other programmers have faced a similar issue; cStringIO,
> > ''.join([mydata]), map( file.write, [mydata]) are but some attempts at
> > making this process more efficient by jamming t
On Sun, 2004-12-19 at 23:43, Jp Calderone wrote:
> On Sun, 19 Dec 2004 23:12:27 -0500, Adam DePrince <[EMAIL PROTECTED]> wrote:
> > [snip]
[snip]
to free the memory, of course.
>
> The support of iterators is a cool idea, but I'm not sure
> it is actually useful.
024 items, so to
accommodate users who don't want to peel off and hold in memory 1024
iteration.next()'s, you can set an optional parameter to a smaller
value.
I'm not sure where to take this as a "next step." It seems too small a
change for a PEP. Any ideas?
uot;__main__":
print linear_space( 1.0, 2.0, 10 )
Running it gives you:
[1.0, 1.1001, 1.2, 1.3, 1.3999, 1.5,
1.6001, 1.7002, 1.8, 1.8999, 2.0]
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
quot;enterprise" class? The same was true 20 years ago -
but it was the mere presence of the computer that served a similar
role. If you were really enterprise class, you used COBOL. And if you
were in the wannabe category, you got yourself a PET 20 and told it what
to do in BASIC.
> (mumbles into beard and drools quietly in the corner).
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
wandering onto [EMAIL PROTECTED] and having
strong opinions in favor of BASIC is sort of like wandering into a
Hasidim temple on Yom Kippur and talking about the salvation of Jesus
while munching on a ham and cheese sandwich? Don't be surprised if you
have trouble making friends.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
Excel in 2
> > minutes.
What you describe is a political, not technical, challenge.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2004-12-17 at 01:49, Andrew Dalke wrote:
> Adam DePrince
> > During the 1980's BASIC was the language to embedd into the ROM's of the
> > computers of the day. This was in a misguided effort to make computers
> > understandable to their target audien
ay of writing what you are tring to write is as follows:
test.py contains:
for root, dirs, files in os.walk('t:\'):
if root(-4:-2) == "20": continue
# Do stuff
[EMAIL PROTECTED] help]$ python test.py
.
./dir1
./dir1/content
./dir2
./dir2/content
./dir2/templates
Oh, and my directory structure is ...
# bash -c 'mkdir -p dir1/200{0,1} dir1/content \
dir2/200{0,1,2,3,4} dir2/{content,templates}'
Does this help?
- Adam
>
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
preted lang if it's similar to BASIC.
> >
> >
> >
>
> Is a Ferrari similar to a horse-wagon? Yes, they both have 4 wheels.
No, it is not better than a horse. The horse is more reliable and on
any given day you can count on it going further before it needs service.
of hockey games... ;)
When I read that I parsed it as reading "I'm Danish; my spouse plays a
mean game of hockey."
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
e word each is (scatological, sexual, religious, etc.) But you are
forced to memorize the same list of curse words over and over again in
order. This is the BASIC way of learning to program.
Don't do it, unless your goal is simply to embarrass and insult
programmers.
Adam DePrince
ash value, but yours
are different.
A hash value is simply a probabilistic mechanism to quickly determine if
two objects must be different, or to select a bin in a hash table.
Two different objects are allowed to have the same hash value, but two
objects that are the same must have the same
ts in the JVM, limiting the size of your
procedural program masquerading as a class. Perhaps that is a good
thing.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
lature and behavior similar to existing mathematical constructs.
Doing this will afford you the opportunity to stand upon the shoulders
of giants as you go about your work. And to properly stand upon those
shoulders, we must match the theoretical models used. That means we
need more, not fewer, immutable counterparts to most of our datatypes.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
ython. You might find this weird, but
...
"anystring"[0] == "anysring"[0][0][0][0][0]
is always true. Taking an element returns the character as a string of
length 1.
Think in terms of maping here. Don't say ...
for ...
Think ...
message = map( ord, message )
or
message = [chr( (ord( x ) + 3 )%256) for x in message]
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
you go about your work. And to properly stand upon those shoulders, we must match the theoetical models used. That means we need more, not fewer, inmutable counterparts to most of our datatypes.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
ves.
When I think of Python in emotional terms. A plush toy like Tux is more
appealing.
As for python2.png ... does the snake get all smushed up in the gear if
it turns?
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
t line,
f.unreadline( line )
line = f.readline()
print line,
line = f.readline()
print line,
Running this prints:
a
b
c
c
d
Hope this helps.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
pipes in Windows NT
Pipes in Unix
Comx: where x is your com port in DOS
Sockets
gzip and zlib file objects; this file was described as being *so* large
that it should not be read into memory. IIRC seek operations are
linear; while it is correct you can seek backwards, I don't think you
woul
both, then:
def a():
something = 1
somethingelse = 2
return something,somethingelse
x,y = a()
This makes the code clear and easy to understand.
Navré je ne pas répondre en français.
- Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
s
weaknesses with respect to complexity and the ability to partition
knowledge.
Forget goggle. Go to Amazon and get some texts on OOPL. Learn C++,
Java, Python for that matter. Practice casting problems as classes in
Python and submit them here for praise and criticism.
Lastly, Perl is a
K * X + Y for some unsigned 4 bit value; on the V20-V30 it was an
undefined operation. What this an accident? I don't know, but a lot of
assembly coders came to depend on the one or two CPU cycles it would
save over a proper mul and add. One or two cycles per array reference
was a big thing back then ...
Anyhow, sorry about babbling on about this non-python related nonsense
and good luck.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
Now promise me that you will never,
ever do this in code you consider yourself proud of. Realize I'm
sharing this in the same spirit that kids in a drivers ed class might
view gory accident pictures.
Fortunately for you, lists are mutable. Assigning to a auto-magically
makes it part of yo
x27;t have any mutex
operations. You get the idea.
Unless mutex calls are rare, or your code simple, you might spend a
while. Largely this problem is intractable, even with simplifications,
but it is done which is why safety critical programs are (well, should
be) small and their languages not
On Wed, 2004-12-08 at 16:22, Steven Bethard wrote:
> Adam DePrince wrote:
> > The use of None as the default parameter was on purpose; the lack of
> > "magic" in python is often cited in religious wars between python and
> > perl aficionados. Use of get(something,
On Wed, 2004-12-08 at 15:06, Steven Bethard wrote:
> Adam DePrince wrote:
> > If your data is sparse you might want to consider using a dictionary
> > where the key is a tuple representing the coordinates.
> >
> > a = {}
> > a[(0,0)] = 0
> > a[(0,1)] = 1
On Wed, 2004-12-08 at 15:02, Steven Bethard wrote:
> Adam DePrince wrote:
> > def flatten( i ):
> > try:
> > i = i.__iter__()
> > while 1:
> > j = flatten( i.next() )
> > try:
> >
t it up Friday night and take the weekend off. Just make sure you
plug your laptop into the wall before you go home.
>
> Is this reasonnable to do on 10^8 elements with repeats in the keys? I
> guess I should just try and see for myself.
Repeats in the keys don't matter.
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
er(['F']) ])
def flatten( i ):
try:
i = i.__iter__()
while 1:
j = flatten( i.next() )
try:
while 1:
yield j.next()
except StopIteration:
pass
except AttributeError:
yield i
if __n
der using a dictionary
where the key is a tuple representing the coordinates.
a = {}
a[(0,0)] = 0
a[(0,1)] = 1
a[(1,0)] = 2
a[(1,1)] = 3
a[(2,0)] = 4
a[(2,1)] = 5
a[(3,0)] = 6
a[(3,1)] = 7
a[(4,0)] = 8
a[(4,1)] = 9
>>> a.get( (3,0), None )
6
>>> print a.get( (5,0), None )
None
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
isting object.
When strings are compiled, they are interned, so ...
>>> "abc" is "abc"
True
>>> "abc" is ("ab" + "c")
False
>>> "abc" == ( "ab" + "c" )
True
>>> "abc&q
een and moves on. Would it be
> correct to say that you want the program to block on the creation of
> each button until it was pressed?
>
> Typically, GUI's rely on the notion of a callback. You create a widget,
> assign some function to be called when something happens and then enter
> your "mainloop" where you wait. If you want your rings to be created
> with button presses then you should be creating them in the button
> callbacks ...
>
> - Adam
> >
> > Using Python 2.3, IDLE and Win2k.
> >
> > Thanks for your time
> >
> > Jean Montambeault
> Adam DePrince
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
the notion of a callback. You create a widget,
assign some function to be called when something happens and then enter
your "mainloop" where you wait. If you want your rings to be created
with button presses then you should be creating them in the button
callbacks ...
- Adam
>
> Using Python 2.3, IDLE and Win2k.
>
> Thanks for your time
>
> Jean Montambeault
Adam DePrince
973-723-8597 cell voice/tdd
973-983-7576 home voice/tdd
--
http://mail.python.org/mailman/listinfo/python-list
tead of data[i]
>
>
>
>
> __
> Do you Yahoo!?
> Yahoo! Mail - You care about security. So do we.
> http://promotions.yahoo.com/new_mail
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
a] )
>>> set_b = Set( [(i,round(j)) for i,j in b] )
>>> set_a.intersection( set_b )
Set([(123, 2.0), (123, 1.0), (123, 8.0)])
Or you could say ...
>>> set_a, set_b = [[Set((i,round(j))) for i,j in s] for s in (a,b )]
Adam DePrince
--
http://mail.python.org/mailman/listinfo/python-list
80 matches
Mail list logo