Sandip Bhattacharya wrote:
for x in string:
if x in chars:
string[i] = ''
I just have a hangover from other languages, but I really wanted to
know how Python handles iteration over a variable which is being
changed within the loop itself. Is the "for" condition evaluated in
Liam Clarke wrote:
4) WHAT IS WITH THE STUPID SYMBOLS EVERYWHERE LARRY??!!
I'm not referring to the $ & @, I can see how they could be useful,
although with a list -
@dude = (1, 2, 3), to obtain the 2nd value I would expect $d = @dude[1],
not $d = $dude[1], that's counterintuitive also.
(I am a
for x in string:
if x in chars:
string[i] = ''
I just have a hangover from other languages, but I really wanted to know
how Python handles iteration over a variable which is being changed
within the loop itself. Is the "for" condition evaluated in every loop?
- Sandip
__
Orri Ganel wrote:
Kent Johnson wrote:
Jacob S. wrote:
Try writing the code to do what lstrip actually does
- its much harder. So the library includes the more
difficult function and lets you code the easy ones.
def lstrip(string,chars=' ')
string = list(string)
t = 0
for x in string:
Kent Johnson wrote:
Jacob S. wrote:
Try writing the code to do what lstrip actually does
- its much harder. So the library includes the more
difficult function and lets you code the easy ones.
def lstrip(string,chars=' ')
string = list(string)
t = 0
for x in string:
if x in chars:
Jacob S. wrote:
Try writing the code to do what lstrip actually does
- its much harder. So the library includes the more
difficult function and lets you code the easy ones.
def lstrip(string,chars=' ')
string = list(string)
t = 0
for x in string:
if x in chars:
string.re
Interesting topic.
Jacob,
Writing library code is a difficult and unrewarding task
- I've been there so I sympathise, however...
I wouldn't say that...
So, how would one go about this in a non broken code way? Don't they
have
something like what I'm requesting.
Its not broken, its just different to
On Thu, 3 Feb 2005, Liam Clarke wrote:
> Had the *ahem* joy of learning Perl last night. Egad. Wrote the script
> in Python to get it right, and then 'translated' it to Perl.
Hi Liam,
I strongly recommend sending the Perl code to that Perl-beginners mailing
list referenced earlier. I'm sur
On Feb 3, 2005, at 00:42, Liam Clarke wrote:
I don't find it that bad. Ruby does it as well, and it's perfectly
readable. It's more or less equivalent as if condition: and
if(condition): both being valid in Python.
Yeah, but you'd never call a function foo like this-
x = foo
in Python. It's just g
> > Ah! Check to see if there's a "sets.py" program somewhere in your
> > current working directory. It's very likely that Python is picking
> > that up, instead of the 'sets' standard library module.
>
> You're a genius! That's exactly what I'd done.
Hi Glen,
I'd attribute it not to genius,
Hello!
> Actually IIRC Perl *invented* regexes as we know them. The "standard"
> regex syntax is known as "Perl regex syntax".
Regex are way older than Perl. The roots are in the Fourties(!).
They were first used in the editor qed, then ed, then sed and eventually
grep.
Then awk, emacs, v
> I don't find it that bad. Ruby does it as well, and it's perfectly
readable. It's more or less equivalent as if condition: and
if(condition): both being valid in Python.
Yeah, but you'd never call a function foo like this-
x = foo
in Python. It's just good to be able to say that a function a
On Wed, 2005-02-02 at 22:02, Danny Yoo wrote:
> On Wed, 2 Feb 2005, Glen wrote:
>
> > [EMAIL PROTECTED] glen]$ idle
> > set([34, 36, 38, 39])
> > Failed to load extension 'CodeContext'
> > Traceback (most recent call last):
> > File "/usr/local/lib/python2.4/idlelib/EditorWindow.py", line 737, i
(damn, forgot to add the main part of my argumentation)
I learnt Perl as well, a few years ago. It was the first scripting
language I came across (all I knew before that were C, Turbo Pascal,
and a few calculator programming languages), so I immediately fell in
love with its string manipulation
On Feb 2, 2005, at 23:18, Liam Clarke wrote:
1) I'll use Perl for the regex stuff from now on, Perl is obviously
built for this.
Actually IIRC Perl *invented* regexes as we know them. The "standard"
regex syntax is known as "Perl regex syntax".
2 ) There's More Than One Way To Do It makes debugg
I got nothing on your Perl rant, but in response to the subject line...
http://www.snopes.com/legal/arizona.htm
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Glad someone else thinks so.
I tried getting into Perl. The rational made perfect sense and I had picked
up several languages by then. Tried. Hated it. Bounced off it. It's like
reading alphabet soup. IMHO they took what was wrong with Shell scripting,
AWK, Sed and a few other languages and
Hi,
Had the *ahem* joy of learning Perl last night. Egad. Wrote the script
in Python to get it right, and then 'translated' it to Perl. Does the
style of coding Python engenders suit the Perl environment in anyone's
experienc? AFAI can see there is no real 'style' to Perl, apart from
white noise
I would at least introduce some functions. For example each case of your command handling loop could
be broken out into a separate function. If there is a lot of shared state between the functions then
make them all class methods and put the shared state in the class. Maybe all the drawing comman
On Wed, 2 Feb 2005, Glen wrote:
> [EMAIL PROTECTED] glen]$ idle
> set([34, 36, 38, 39])
> Failed to load extension 'CodeContext'
> Traceback (most recent call last):
> File "/usr/local/lib/python2.4/idlelib/EditorWindow.py", line 737, in
> load_standard_extensions
> self.load_extension(nam
My setup is Mandrake 10.0 which came with python 2.3 and a standard
Python 2.4 build/install.
I always start Idle from an icon on my taskbar, when I click the icon,
Idle starts after a second but a small rotating timer appears over
the taskbar for 30 seconds and then disappears.
If I close Idle im
On Tue, 1 Feb 2005 19:08:41 +0200
Mark Kels <[EMAIL PROTECTED]> wrote:
Hi Mark,
> Hello,
> I got some Tkinter questions that I need the answer for to complete a
> little project of mine:
> 1. How can I make the program to open in a X*Y sized window ?
from Tkinter import *
root = Tk()
root.geomet
Even better :
import numarray
m = numarray.arange(16,shape=(4,4))
numarray.sum(m)
array([24, 28, 32, 36])
numarray.sum(axis=1)
array([ 6, 22, 38, 54])
Pierre
Kent Johnson a écrit :
Kent Johnson wrote:
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_h
Kent Johnson wrote:
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_hardware/numarray
that implements array mathematics. I use it for pixel map manipulation
in pygame, so it's relatively fast.
Here is one way to do what you want using numarray:
Here
On Feb 2, 2005, at 10:19, Ewald Ertl wrote:
Hi!
Using binary operations:
a='0x87BE'
str(hex(int(a,16) & 0xFF))
'0xbe'
str(hex((int(a,16) & 0xFF00) / 0xFF))
'0x87'
HTH Ewald
Actually, the int conversions aren't even necessary.
>>> hex(0x87BE & 0xFF)
'0xbe'
>>> hex((0x87BE & 0xFF00) / 0xFF)
'0x8
Liam Clarke wrote:
There's a specific package for arrays
http://www.stsci.edu/resources/software_hardware/numarray
that implements array mathematics. I use it for pixel map manipulation
in pygame, so it's relatively fast.
Here is one way to do what you want using numarray:
>>> import numarray
Cr
Hi!
Using binary operations:
>>> a='0x87BE'
>>> str(hex(int(a,16) & 0xFF))
'0xbe'
>>> str(hex((int(a,16) & 0xFF00) / 0xFF))
'0x87'
>>>
HTH Ewald
on Wed, 2 Feb 2005 15:10:36 +0800 jrlen balane <[EMAIL PROTECTED]> wrote :
---
Hello all,
> > So, how would one go about this in a non broken code way? Don't they
> have
> > something like what I'm requesting.
If not,it's a challenge you can implement yourself! Ever use QBasic?
Had a command -
a$ = inkey$(1)
Which would return a key press as a$.
Very handy for 'press a
Hi Danny,
I think that learning Python naturally leads to learning programming.
It's like learning to fly, you learn to fly in a Cessna or Piper
Cherokee. Simple, elegant, easy to operate. You can then focus on the
art of flying, not on how exactly you lower the flaps. Then, once
you're good at f
> >>> hexa = '0x87BE'
> >>> upper = int(hexa[2:4], 16)
> >>> lower = int(hexa[4:6], 16)
FWIW :
You don't need to strip the '0x' from the front, int() is
smart enough to do that automatically for base 16
conversions...
Alan G.
___
Tutor maillist -
> The community is one of the things I particularly like about Python. I
> always hated asking a question in the Perl newsgroups; although you
> usually got an answer, you were almost certain to be told you're stupid
> for not already knowing it.
Hi Terry,
Just to act as Devil's advocate: the
Jacob,
Writing library code is a difficult and unrewarding task
- I've been there so I sympathise, however...
> So, how would one go about this in a non broken code way? Don't they
have
> something like what I'm requesting.
Its not broken, its just different to what you want.
What you want is mu
On Tue, 1 Feb 2005, Jacob S. wrote:
> Also why shouldn't string methods include stuff like lstrip which do
> precisely what I request?
Hi Jacob,
I think the confusion here is that, in Python, strings can be considered a
concrete single thing, but they can also be considered an ordered
collect
> I don't know who's going crazy here... but I checked that straight
from the
> python 2.4 interpreter...
>
> Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
on win32
> Type "help", "copyright", "credits" or "license" for more
information.
> >>> a = "go on long buddy"
> >>> a.l
> I was just wondering, what magic can you do with classes?
You can define your own types. Thats what classes are for.
Those types can be as 'magic' as your imagination
(and programming skills!) allow.
> other classes are interesting to subclass? I've seen Object too, but
I
> don't understand wha
jrlen balane wrote:
i have a 4 digit hex number (2 bytes) and i want to separate it into 2
digit hex (1 byte each) meaning i want to get the upper byte and the
lower byte since i am going to add this two.
how am i going to do this?
should i treat it just like a normal string?
please help, thanks.
e
36 matches
Mail list logo