On Fri, 4 Feb 2005, alieks lao wrote:
> Once again i have a question concerning something from the tutorial im
> being tortured by.
>
> ___
> x.y= \ x (dot)y(dot)
> /__ i
>i
>
> How would i express this in python.
> If the above doesn't make any sense to ya'll.
> It's at
That looks fine size wise. Thanks.
Ismael Garrido wrote:
Patrick Kirk wrote:
Hi all,
I'm writing an application that will distributed by download and want
it to be as small as possible. The target platform is Windows.
Use UPX, 7Z and NSIS. ;-) (and in that order, too :-P)
That's with Py2exe, ne
Once again i have a question concerning something from
the tutorial im being tortured by.
___
x.y= \ x (dot)y(dot)
/__ i
i
How would i express this in python.
If the above doesn't make any sense to ya'll.
It's at the bottom of this page>>>
http://www.pentangle.net
The binary value is the same as the hex value.
The binary representation is 00010100, but
unfortunately Python doesn't support binary in
its string formatting(although it does in int()!
Uh, question. Why not? It seems that all simple types should be included.
Since the computer stores it as bin
My two bits.
1) Download py2exe found here
http://py2exe.sourceforge.net/
2) Make a setup file -- intructions can be found through above link, I
think.
(Hey that rhymes!)
3) Ask if you want my totally cool automation technique
4) Ask more questions, go on we don't mind.
HTH,
Jacob Schmidt
Hi,
I i
Andrew D. Fant said unto the world upon 2005-02-04 18:27:
Alan Gauld wrote:
I said awk was easier to learn but less capable than Perl.
Perl is capable of things that awk can only dream of!
Surely you jest, Alan. :-)
I'm prettry sure he means it. And stop calling him Surely ;-)
Brian vdB
__
an experience where a rogue process or editor has trashed the
indentation in your Python and how you recovered from it.
Only in mailing list emails!!
I'll second that!!!
Jacob
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/
Hi,
I intend to create compiled python binaries on linux.
I understand that freeze can be used to do this.
But I have few doubts i would like to clarify.
1. In the freeze documentation i found the lines:
"One tricky issue: Freeze assumes that the Python
interpreter and
environment you're using t
Alan Gauld wrote:
I said awk was easier to learn but less capable than Perl.
Perl is capable of things that awk can only dream of!
Surely you jest, Alan. :-)
Both perl and awk are turing complete, hence anything perl can do, awk
can do as well. Now, as to which one would be easier to work with fo
Now this is a concrete example of how lambda simplifies code, at
least
for me because it does not clutter my mental name space. Also it is
much shorter. However it should be said that this is very much a
question of taste.
Agreed. Which would make it pointless to remove in a future release. ;-)
H
On Sat, 5 Feb 2005, Alan Gauld wrote:
> Marilyn,
>
> > I'll whisper that I'm a tiny bit disappointed to see the vaguely
> > demeaning 'are you joking' theme that has emerged in here. It's
> > unusual for us to be anything but generous and kind with each other.
> > I guess this is a hot topic. :
> an experience where a rogue process or editor has trashed the
> indentation in your Python and how you recovered from it.
Only in mailing list emails!!
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Marilyn,
> I'll whisper that I'm a tiny bit disappointed to see the vaguely
> demeaning 'are you joking' theme that has emerged in here. It's
> unusual for us to be anything but generous and kind with each other.
> I guess this is a hot topic. :^)
Languages (and editors) are always emotional to
> I'm writing an application that will distributed by download and
want it
> to be as small as possible. The target platform is Windows.
In that case distribute Python source not executables!
Or write in assembler...
> For the GUI toolkit, I am looking at wxPython and tkinter. For a
small
> app
> > I think its clearer! It says that the first two things happen
> > or else the last thing. Plain English.
>
> That's apparently subjective then.
So it seems. You always assume that whats clear to you will be
clear to all! This discussion proves it ain't necessarily so...
> eye. (x**2 for x in
> Now who's joking?
:-)
> Are you saying that
>
> switch var:
> case 'a':
>print 'a'
> ...
> default:
>print 'default case'
>
> Is less clear and maintainable than
I don;tthink I said (certainly didn't mean) less clear, but
yes it is less maintainable.
But then...
> def do_this_fu
On Fri, 4 Feb 2005, alieks lao wrote:
> > Just out of curiosity, which tutorial are you reading?
>
> heres the url...
> http://www.pentangle.net/python/
Hi Alieks,
Ah, ok, that makes sense now.
Michael William's tutorial assumes an environment where some third-party
modules, like Numeric, ha
On Fri, 4 Feb 2005, Smith, Jeff wrote:
> On the indentation topic. I would be curious to know if anyone has had
> an experience where a rogue process or editor has trashed the
> indentation in your Python and how you recovered from it.
[Meta: switching subject line again --- this conversation
Numeric is an add-on module, not part of the standard distribution. You have to download it and
install it. (I'm surprised your tutorial doesn't point that out!) Numeric is still in use but there
is a newer version called numarray. You can read about them both here:
http://www.pfdubois.com/numpy/
On Fri, 4 Feb 2005, alieks lao wrote:
> in this tutorial it's telling me to
>
> "from Numeric import *"
>
> to load array functions
> but it doesn't work is there a replacement for
> "Numeric" or are arrays built in functions?
Hi Alieks,
Just out of curiosity, which tutorial are you reading?
in this tutorial it's telling me to
"from Numeric import *"
to load array functions
but it doesn't work is there a replacement for
"Numeric" or are arrays built in functions?
thanks
alex
__
Do you Yahoo!?
Yahoo! Mail - Helps protect you from n
I had a problem with nested
while 1:
... .
...
...
break
blocks. So, I got some sleep, fixed it, and now do everything in my
power to not nest while 1 - break blocks.
Not that it's really relevant.
On Fri, 4 Feb 2005 17:18:49 -0500, Smith, Jeff <[EMAIL PROTECTED]> wrote:
> Please d
On Friday 04 February 2005 03:42, Alan Gauld wrote:
> On Thursday 03 February 2005 17:41, Alan Gauld wrote:
> >> In fact the best style of all is neither of the two I showed,
> >> its actually this - which early everyone hates when they see it!
> >>
> >> inf f(x)
> >>{
> >>bah()
> >>}
>
Please don't take offense. I should have included the smiley. To
reiterate an earlier statement: I like Python...a lot. But as with all
langauges there are some things I don't like and I believe they were
left out for the wrong reasons.
On the indentation topic. I would be curious to know if
Patrick Kirk wrote on Fri, 04 Feb 2005 21:47:58 +:
> I'm writing an application that will distributed by download and want it
> to be as small as possible. The target platform is Windows.
Python isn't the right choice if your aim is minimum "executable" size. I
wouldn't worry too much about
I think Danny was saying that if you don't like:
if var == 'a':
print 'a'
elif var == 'b' or var == 'c':
print 'b or c'
elif var == 'd':
pass
else:
print 'default case'
you might like his dispatch scheme. And it has been mighty nice and
handy for me since he taught me, in some specia
Now who's joking? Are you saying that
switch var:
case 'a':
print 'a'
case 'b' or 'c':
print 'b or c'
case 'd':
pass
default:
print 'default case'
Is less clear and maintainable than
def do_this_fun
Hi all,
I'm writing an application that will distributed by download and want it
to be as small as possible. The target platform is Windows.
For the GUI toolkit, I am looking at wxPython and tkinter. For a small
application with only 4 working forms, which can be expected to produce
the small
Roel,
That was well put. Too many people complain about certain language
features because of the way they are abused independent of whether or
not they have any value when used properly. In that case it's throwing
the baby out with the bath-water...and won't achieve anything since bad
programmer
Smith, Jeff wrote:
IMHO, if/elif/else statements are far more abused than either switch or
ternary but I certainly wouldn't argue they should be removed from the
language.
IMHO, if it's true that if/elif/else statements are more abused than
ternaries, then it's only because they're *used* far more
On Fri, 4 Feb 2005, Smith, Jeff wrote:
> What you are try to do is "execute a block of code based on the value of
> a single statement." if/elif doesn't do that and thereby introduces the
> possibility of errors.
>
> switch on-this:
> case 'a':
> do something
> case 'b
Alan Gauld wrote:
BTW, Steve McConnell recommends your favorite too in Code Complete.
But
he also didn't manage to convince me.
Thats where I first found it, I looked up a couple of references and
the
message was consistent, so I changed my style. (And my emacs settings
:-)
I'll have to read that
Alan Gauld wrote:
foo = x and y or z
is much less elegant than
foo = x ? y : z
You must be joking too... You think that
x and y or z
is as clear as
x ? y : z
I think its clearer! It says that the first two things happen
or else the last thing. Plain English.
That's apparently subjective then. I kn
> Disagree to disagree again. I certainly don't think Perl is less
> capable than awk.
Neither do I...
>> Really? Why for? awk is far easier to learn than Perl
>> - and far less generally capable! - but it makes Perl seem
>> positively verbose!
I said awk was easier to learn but less capa
> Does anybody know how to convert a HEX into a BINARY?
The easiest way I know is to use a lookup table on
the octal representation.
def bin(n):
bins = ['000','001','010,'011','111']
result = ''
for c in oct(n):
result += bins[int(c,8)]
return result
HTH,
Alan G
Author
> But I'm looking for a solution to convert a Hex number
> into binary, decimal, interger numbers.
WE need to be very specific about our terminology here.
All numbers in the computer are stored in binary.
Only the string representation on the screen is
in decimal, octal, hex etc.
> What is the
Max Noel wrote:
>
> According to the Jargon file, this one is called Whitesmiths
> style. I tend to use Allman style myself, but given the code
> completion, spellchecking, etc. in modern IDEs, I suspect it's
become
> more a question of personal preference than anything else.
>
> A bit
> I like to know, if it's possible to convert a Hex number into
> String or other formats?
Use the string format operator:
>>> print "%X" % 0xB5
B5
>>> print "%X" % 181
B5
Lowercase '%x' uses lowercase letters on output...
Or use the int() function with a base argument to go the other way:
>
> >
> > X
> > X
> > X
> >
> > Thats Python! Since you are on this list I suspect you do write
> > "code like that" Its just Guido removed the now extraneous {}...
>
> My favorite, Allman style, is also Python if you remove the {} !
Yep but the braces in Allman
> Do you have a link to these studies? I'm always skeptical about the
> methodology in those studies, but I'm willing to be proven wrong.
Check "Code Complete" by Steve McConnel, he gives the explanation
and also several references. One that I found from a quick glance
is "Hansen & Yim, 1987".
> > foo = x and y or z
> >
> > is much less elegant than
> >
> > foo = x ? y : z
>
> You must be joking too... You think that
>
> x and y or z
>
> is as clear as
>
> x ? y : z
I think its clearer! It says that the first two things happen
or else the last thing. Plain English.
'?:' means absolutel
Thank you all for answering my question. I thought it would be some
misunderstanding on my part. The example Andrei made was very
telling.
Andrei wrote:
s = "d:/tests/test.txt"
class dummyfile(object):
>... def open(self, *args):
>... print "dummyfile.open
> What you are try to do is "execute a block of code based on the
value of
> a single statement." if/elif doesn't do that and thereby introduces
the
> possibility of errors.
In that case the best solution is a dictionary jump table.
That is more maintainable than either and much faster too.
And i
Tamm,
Try searching before you get snippy on a group where people are
helping you for free. This question gets asked a lot, and the answer
can be found all over the place.
A particularly comprehensive thread discussing the issue can be found
at
http://groups-beta.google.com/group/comp.lang.pytho
I will give some credit to you for asking a clear question. You included
- a clear description of what you want to do
- sample data
- desired results
- code that attempts to solve the problem
When all of these are present I am much more likely to respond. The first three elements especially
make a
Please give us an example of what you would like to do since we don't seem to understand. Imagine
there is a function that does exactly what you want and show how you would use it and what results
you would get.
Repeating the same question is not likely to get a better answer, just more
guesses
Disagree to disagree again. I certainly don't think Perl is less
capable than awk. And awk is only easier to learn because there's less
to it. If someone only wanted to use Perl for exactly what awk does I
suspect they would find Perl easier. And awk's terseness is part of
what I don't like abo
The problem with if/elif is that it doesn't express what is actually
gong on.
What you are try to do is "execute a block of code based on the value of
a single statement." if/elif doesn't do that and thereby introduces the
possibility of errors.
switch on-this:
case 'a':
Ok, thank you.
Does anybody know how to convert a HEX into a BINARY?
Best regards
Heiko
-Original Message-
From: Pierre Barbier de Reuille [mailto:[EMAIL PROTECTED]
Sent: Friday, February 04, 2005 2:55 PM
To: Tamm, Heiko
Subject: Re: [Tutor] Hex to Str - still an open issue
Hello.
Kent once again you have responded incredibly quickly in a most
helpful manor. I sometimes wonder if the old reference to a
"Kent-bot" has some truth to it.
Thanks again, I will play with it and keep on going.
Scott
___
Tutor maillist - Tutor
You might be interested in these:
http://groups-beta.google.com/group/comp.lang.python/msg/c2cb941ea70dcdad
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/111286
Kent
Tamm, Heiko wrote:
Thank you, Pierre,
But I'm looking for a solution to convert a Hex number into binary, decimal,
interge
Thank you, Pierre,
But I'm looking for a solution to convert a Hex number into binary, decimal,
interger numbers.
E.g.:
What is the the binary value of the hex number 1F4.
Is there a function available, or how can it be done?
Kind regards and a nice weekend
Heiko
-Original Messa
Hello Heiko,
I do not really know what you like to get, but the hex-number's in Python are
usedd
in a numeric representation. As far as I have seen in the interpreter, this
depends
on the value:
>>> a=0xabccddd
>>> type(a)
>>> a=0xaabb
>>> type(a)
If you like to see the nu
Use the hex() function to convert an integer to a hex string representation:
>>> hex(54)
'0x36'
>>> hex(0x54)
'0x54'
or for more control use %x string formatting:
>>> '%x' % 54
'36'
>>> '%04X' % 0xab
'00AB'
etc.
Kent
Tamm, Heiko wrote:
Hello,
I like to know, if it's possible to convert a Hex
Given you have a number in 'a' :
hex(a)
returns the hexadecimal representation of 'a' as a string !
You can also try :
"%x" % a
After that, I don't know if there is some builtin to print a number in
any base you want !
Pierre
Tamm, Heiko a écrit :
Hello,
I like to know, if it's possible to conv
Hello,
I like to
know, if it's possible to convert a Hex number into String or other
formats?
How can it
be done?
Kind
regards
Heiko
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
You need to reset your items_dict when you see an hg17 line.
Here is one way to do it. I used a class to make it easier to break the problem into functions.
Putting the functions in a class makes it easy to share the header and counts.
class Grouper:
''' Process a sequence of strings of the f
Chad Crabtree wrote:
How about a concrete example where lambda is more elegant than a
named
block of code
aList=['a','bb','ccc','','ee']
bList=aList[:] #deep copy
assert not bList is aList
def sortByLength(item1,item2):
return cmp(len(item1),len(item2))
bList.sort(sortByLength)
assert bLi
Hello once more.
I am stuck on how best to tie the finding Unique Items in Lists ideas to my file
I am stuck at level below: What I have here taken from the unique
items thread does not work as I need to separate each grouping to the
hg chain it is in (see below for examples)
import sys
WFILE=o
Alan Gauld wrote:
Look at it conceptually:
X
X
X
Thats Python! Since you are on this list I suspect you do write
"code like that" Its just Guido removed the now extraneous {}...
My favorite, Allman style, is also Python if you remove the {} !
BTW, Steve McConnel
Alan Gauld wrote:
In fact the best style of all is neither of the two I showed,
its actually this - which early everyone hates when they see it!
inf f(x)
{
bah()
}
Yikes. We use that style at work. At first I found it ugly, but I
thought I'd get used to it after a while. Well, 3 years
Alan Gauld wrote:
I also wish Python would take up the C ternary operator
which is also quite clear and elegant.
:-)
You joke I assume? ':?' is clear? Its succinct but also
prone to abuse. I don't think the Python equivalent
foo = x and y or z
is much less elegant than
foo = x ? y : z
You must
On Feb 4, 2005, at 09:09, Alan Gauld wrote:
Correct. The style you show (which I called Pascal style) is
the one that doesn't work. K&R style
if(foo) {
bar;
}
Is the one that won the shootout.
With the outsider(which I dont know a name for!) beating both...
if (foo)
{
bar;
}
According to
> and function. Its like the theory behind how elictricity
Yikes! Did I really manage to type elictricity
And I can't blame finger trouble, e and i are miles
apart on the keyboard!
Blush
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail
> I've tried this and I cannot figure out why this does not work.
So what happens?
And how are you closing the file?
> open(item,'w').write(open(item,'r').read().replace(' ',''))
I can't see the obvious flaw, but using anonymous files(*) is not
a good idea IMHO.
(*)Unlike anonymous functions
> So the first argument evaluated is "self" ... and in your case
"self" is
> "open(item, 'w')" so the first thing your line does is opening for
> writing the file named by "item" and as "w" empty the file ... you
can
> read it afterward, it will be empty !
Ah! well spotted Pierre, I hadn't noticed
On Thursday 03 February 2005 17:41, Alan Gauld wrote:
>> In fact the best style of all is neither of the two I showed,
>> its actually this - which early everyone hates when they see it!
>>
>> inf f(x)
>>{
>>bah()
>>}
>
>Ugh. Alan, I won't even try to dispute the study. But if I have
> Although, (and this will be rough) a list comprehension would be
> probably do the same thing
> j=[1, 2,3,4, 5,6,7,8]
>
> q = [if not item % 2 for item in j]
I think you mean:
q = [ item for item in j if item % 2]
item % 2 will return zero = false on even numbers, so
your test is true for od
> I'm with Jeff on this one - I've yet to see the light regarding
> lambda's. I understand they're used through-out Tkinter GUI stuff
They often are in practice although they are rarely (never)
necessary(*). But they are a convenient way of defining a one
liner function without the overhead of cer
> > I disagree Jeff. It does need lambdas to do FP properly, and
>
> Well, we'll have to continue to disagree on that. ;) Personally, I
> can't help but think that 'lambda' is descriptive only to people
> who've experienced it elsewhere, and that that does *not* include
the
> majority of the progr
> > The reasons for the K&R style of brace winning is to do
> > with the way the brain process structure and despite
> > the subjects stated preference for the 'Pascal' style
> > they still had lower perception scores.
>
> Little nit-picking here:
>
> if(foo)
> {
> bar();
> }
>
> Is not K&R style,
> > Sean, what book/tutor are you using for Haskell?
>
> I'm not Sean,
Oops, sorry, I picked the name from the post I was replying
to, apologies!
> but I'm using Simon Thompson's "Haskell: The Craft of
> Functional Programming", which I find quite good. However, it's a
bit
> odd, in that it almos
> > We'll just have to have to disagree about awk. I starting
learning Perl
> > to avoid learning awk :-)
>
> But awk is smaller and simpler than perl. So it should be faster
> (esp. at startup) for small and simple tasks.
> As usual: Right tool for right task.
awk starts faster but perl is more
Chad Crabtree yahoo.com> writes:
> I've tried this and I cannot figure out why this does not work. I
> figure this has something to do with order of operations. I figured
> someone would know exactly why it doesn't work. Wouldn't this start
> inside parens then from left to right?
>
> open
Alan Gauld wrote:
Sean, what book/tutor are you using for Haskell?
I learned it from "The Haskell School of Expression" which
was OK but very graphics focused, I'd be interested in
recommended second source on Haskell.
as with Max I am reading Haskell: Craft of Functional Programming. I am
abou
On Feb 4, 2005, at 06:39, Chad Crabtree wrote:
I've tried this and I cannot figure out why this does not work. I
figure this has something to do with order of operations. I figured
someone would know exactly why it doesn't work. Wouldn't this start
inside parens then from left to right?
open(ite
Ok, so in Python, arguments are evaluated first, left to right !
The outer-most function used in your sample is :
file.write(self, filename, mode)
So the first argument evaluated is "self" ... and in your case "self" is
"open(item, 'w')" so the first thing your line does is opening for
writing th
77 matches
Mail list logo