If you use vi (vim, I hope), then place something like this in your
.vimrc
set ts=4
set sw=4
set expandtab
set ai
There are a lot more tricks for python in vim (and plugins, and
helpers, and so on), but this is the starting point: tabstops of 4
places, autoconverted in spaces. Also, when shifting
Paul Rubin wrote:
> Ben Finney <[EMAIL PROTECTED]> writes:
>
>>Enumerations with no values are meaningless. The exception
>>``EnumEmptyError`` is raised if the constructor is called with no
>>value arguments.
>
>
> Why are empty enumerations not allowed? Empty sets, empty lists,
> empty dicti
[EMAIL PROTECTED] wrote:
> I am a newbie to Python. I am mainly using Eric as the IDE for coding.
> Also, using VIM and gedit sometimes.
>
> I had this wierd problem of indentation. My code was 100% right but it
> wont run because indentation was not right. I checked time and again
> but still no
Henrique Ferreiro wrote:
>
> O Sáb, 25-02-2006 ás 15:01 -0800, MARK LEEDS escribiu:
>
>>i'm pretty much a python beginner so can anyone recommend a plooting
>>package in python ( simple foating numbers
>>that makes lines or dots with a yaxis and an an xaxis. i don't need
>>fancy drawings ) that
Lonnie Princehouse wrote:
> I plan on writing some documentation that will consist of blocks of
> commentary with interspersed snippets of syntax-colored Python code and
> the occaisional image.
>
> Does anyone know of a package that will take a high level description
> of what I just described an
This seems great, except why can't I compare strings? It seems too
useful when dealing with user input, or parsing messages or config
files.
>>> Weekdays = enum('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat')
>>> Weekdays.mon.__cmp__('mon')
0
Additionaly, perhaps the call method of the enumerati
"Fuzzyman" <[EMAIL PROTECTED]> wrote:
>
>Alex Martelli wrote:
>> Fuzzyman <[EMAIL PROTECTED]> wrote:
>>
>> > What gives ?
>>...
>> > >>> a = []
>> > >>> def f():
>> > return a
>>...
>> > >>> f() += [4]
>> > SyntaxError: can't assign to function call
>>
>> Exactly what the error messa
I am a newbie to Python. I am mainly using Eric as the IDE for coding.
Also, using VIM and gedit sometimes.
I had this wierd problem of indentation. My code was 100% right but it
wont run because indentation was not right. I checked time and again
but still no success. I rewrote the code over agai
Ben Finney wrote:
> Values within an enumeration cannot be meaningfully compared except
> with values from the same enumeration. The comparison operation
> functions return ``NotImplemented`` [#CMP-NOTIMPLEMENTED]_ when a
> value from an enumeration is compared against any value not from the
> sa
Ben Finney <[EMAIL PROTECTED]> writes:
> Enumerations with no values are meaningless. The exception
> ``EnumEmptyError`` is raised if the constructor is called with no
> value arguments.
Why are empty enumerations not allowed? Empty sets, empty lists,
empty dictionaries are all allowed. I don't
Kay Schluehr wrote:
>> The enumerations specified in this PEP are instances of an ``enum``
>> type. Some alternative designs implement each enumeration as its own
>> class, and a metaclass to define common properties of all
>> enumerations.
>>
>> One motivation for having a class (rather than an
The error you're seeing is because you've rebound 'list' to something
else. Try putting "list = type([])" somewhere above your code.
--
http://mail.python.org/mailman/listinfo/python-list
kmkz wrote:
> Lets say my script A executes two other scripts, B and C. B is a Python
> file compiled into an exe and uses the regular black box. C, however,
> is a C++ program that I did not write, and have no access to (besides
> executing it. ie, i don't have its source). I would like to fork o
Greg:
> The only issue I'm having relates to Unicode. MoinMoin and python are
> pretty unforgiving about files that contain Unicode characters that
> aren't included in the coding properly. I've spent hours reading about
> Unicode, and playing with different encoding/decoding commands, but at
> th
Ben Finney wrote:
> Metaclass for creating enumeration classes
> --
>
> The enumerations specified in this PEP are instances of an ``enum``
> type. Some alternative designs implement each enumeration as its own
> class, and a metaclass to define common pro
Grzegorz Smith wrote:
> Hi all. I have got situation: i load data from database(MSSQL) wchich are
> encoded cp1250 and I fill template with that data (Cheetah Template), after
> all i want to save template to file on disk. I'm using
One way to do it:
>>> from Cheetah.Template import Template
>>>
Thanks for your suggestions. I've Python on both my Win32 and Linux
partitions of my laptop. Although, I suppose I should develop my CGI on
the laptop (running Apache) first.
Thanks,
Ben
--
http://mail.python.org/mailman/listinfo/python-list
Dear all,
My lab has been using a Movable Type blog for internal communication
and announcement for a couple of years, but we've now seen the light
and I've set up a MoinMoin wiki. Everything's installed beautifully, so
I'm writing scripts to export all our Movable Type blog posts to wiki
pages. S
Thank you... i was looking in the wrong place cause all i found was
this relatively useless doc:
http://docs.python.org/lib/module-os.html
which says almost nothing.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
>For example... tell windows to move a file named ' XXX ' (one space
>before and one space after the filename). Windows will complain that
>file 'XXX' does not exist. It's correct of course, 'XXX' does not
>exist,
>but ' XXX ' does indeed exist.
>
>Can anyone rescue me fro
Hey Crutcher, thanks for the code, that would work. I'm now debating
using that, or using function arguments to get the variables into the
namespace. This would require knowing the variables in the dict ahead
of time, but I suppose I can do that because it's part of the same
system that creates the
kpp9c wrote:
> os.listdir works great ... just one problem, it packs the filenames
> only into a list... i need the full path and seach as i might i se NO
> documentation on python.org for os.listdir()
Docs for os.listdir() are here:
http://docs.python.org/lib/os-file-dir.html
When all else fails
Greetings,
I was the last time who asked your opinion about Infinite Loops and
crontab. I settled with crontab where in the python program selects a
number of records from a mysql database and then releases Threads (which
is actually CORBA clients) that report to a CORBA server, wait a
respons
os.listdir works great ... just one problem, it packs the filenames
only into a list... i need the full path and seach as i might i se NO
documentation on python.org for os.listdir()
how do i either grab the full path or append it later ...
--
http://mail.python.org/mailman/listinfo/python-list
Thank you for your reply. I will certainly look into those.
Another question:
Lets say my script A executes two other scripts, B and C. B is a Python
file compiled into an exe and uses the regular black box. C, however,
is a C++ program that I did not write, and have no access to (besides
executi
Michal Kwiatkowski wrote:
> def init_arguments(fun):
> def new_f(self):
> var_one = self.attr_one
> var_two = self.attr_two.another_attr
> empty_list = []
>
> fun(self, var_one, var_two, empty_list)
>
> return new_f
>
> @init_arguments
> def method(self, v
Howdy all,
PEP 354: Enumerations in Python has been accepted as a draft PEP. The
current version can be viewed online:
http://www.python.org/peps/pep-0354.html>
Here is the reStructuredText source as it is today. Please discuss it
here so I can see what issues people may have.
PEP:
I was trying to understand the concept of
python looking for modules in sys.path.
So, as it said in "Beginning Python", I went into
my .bashrc file and did
export PYTHONPATH=$PYTHONPATH:~/mytemp
then, i typed pprint.pprint(sys.path) and it
worked.
it was in there
!
Delaney, Timothy (Tim) wrote:
> Ron Adam wrote:
>
>> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
>> on win32
>>
>> I was a bit surprised by them being sorted. I just happend to try
>> d.keys() in place of s2, and it sped up. I was expecting it to be a
>> bit slower.
>
Alex Martelli wrote:
> Ron Adam <[EMAIL PROTECTED]> wrote:
>...
>> Considering the number time I sort keys after getting them, It's the
>> behavior I would prefer. Maybe a more dependable dict.sortedkeys()
>> method would be nice. ;-)
>
> sorted(d) is guaranteed to do exactly the same thin
invitro81 wrote:
> Which one is better w.r.t. memory allocation but also w.r.t. speed:
> ## 1.1 ##
> def forloop(a,b):
> for idx in range(a,b):
> ...
Above preferred to next (for readability) using xrange may help speed
depending.
> ## 1.2 ##
> def whileloop(a,b):
> idx = a
>
Alex Martelli wrote:
> But of course, then the method's body would have to use _.one rather
> than var_one, _.two rather than var_two, and _.empty_list rather than
> empty_list (what a strange name -- does it STAY empty throughout the
> method's execution?!). To me this looks like a small price to
"Crutcher" <[EMAIL PROTECTED]> writes:
> No, I don't disagree that people do this. The history of "Zen and the
> Art of X" dates from "Zen and the Art of Motorcycle Repair", which is
> actually about Zen and Motorcycles.
Actually "Zen in the Art of Archery" by Eugen Herrigel, which was
about an a
Ron Adam <[EMAIL PROTECTED]> wrote:
...
> Considering the number time I sort keys after getting them, It's the
> behavior I would prefer. Maybe a more dependable dict.sortedkeys()
> method would be nice. ;-)
sorted(d) is guaranteed to do exactly the same thing as sorted(d.keys())
AND to be
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
...
> The problem wouldn't be such a problem if Python had implicit self...
> but on the other side, it's another ambiguity.
In your example, you could avoid assigning var_one, but the purpose of
assigning var_two and empty_list obviously would not
Ron Adam wrote:
> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
> on win32
>
> I was a bit surprised by them being sorted. I just happend to try
> d.keys() in place of s2, and it sped up. I was expecting it to be a
> bit slower.
Purely an implementation accident - based
Alex Martelli wrote:
> Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
>...
>> def method(self):
>> var_one = self.attr_one
>> var_two = self.attr_two.another_attr
>> empty_list = []
>> # significant code goes here
>...
> Personally, I would keep pushing back against this app
[EMAIL PROTECTED] wrote:
>> It's faster on my system because d.keys() is already sorted. But that may
>> not be the case on other versions of python.<
>
> In my version it's a little slower. But what system are you using where
> keys is already sorted? IronPython maybe?
>
> Bye,
> bearophile
Michal Kwiatkowski <[EMAIL PROTECTED]> wrote:
...
> def method(self):
> var_one = self.attr_one
> var_two = self.attr_two.another_attr
> empty_list = []
> # significant code goes here
...
> know, I know ;), but maybe there is a way? I would like to code it that way:
>
> @init
Alex Martelli wrote:
> Ron Adam <[EMAIL PROTECTED]> wrote:
>
>> [EMAIL PROTECTED] wrote:
>>> Your solution Steven Bethard looks very intelligent, here is a small
>>> speed test, because sorting a list according another one is a quite
>>> common operation.
>>> (Not all solutions are really the same
Hi all. I have got situation: i load data from database(MSSQL) wchich are
encoded cp1250 and I fill template with that data (Cheetah Template), after
all i want to save template to file on disk. I'm using
newfile = open("template.html",w")
newfile.write(str(template))
newfile.close()
But data enco
Fuzzyman <[EMAIL PROTECTED]> wrote:
...
> > Exactly what the error message says: it's syntactically forbidden to
> > perform any assignment on a function-call.
...
> Cool, thanks. That's what I did, it's just not an error I'd seen
> before. Everywhere else Python evaluates the function call a
Hi!
Perso, I like this...
MCI
--
http://mail.python.org/mailman/listinfo/python-list
Ok, I initially thought the Tkinter route would be too "low level" (Ha,
low level python), but I noticed a link to VTK which looks promising.
Thanks for your quick reply!
Derek.
--
http://mail.python.org/mailman/listinfo/python-list
In article <[EMAIL PROTECTED]>,
Kay Schluehr <[EMAIL PROTECTED]> wrote:
.
.
.
>Lucid in the mid 80s that gone down a few years later. As it turned out
>that time Lisp was not capable to survive in what we call today a
>"heterog
Alex Martelli wrote:
> Fuzzyman <[EMAIL PROTECTED]> wrote:
>
> > What gives ?
>...
> > >>> a = []
> > >>> def f():
> > return a
>...
> > >>> f() += [4]
> > SyntaxError: can't assign to function call
>
> Exactly what the error message says: it's syntactically forbidden to
> perform an
Hi!
I'm building a class that most of methods have similar intro, something
like this:
def method(self):
var_one = self.attr_one
var_two = self.attr_two.another_attr
empty_list = []
# significant code goes here
# ...
It's done for clarity reasons, aliasing most used variabl
"Fuzzyman" <[EMAIL PROTECTED]> writes:
f() += [4]
> SyntaxError: can't assign to function call
It's obvious that that line gives you a syntax error. += is the increment
operator overloaded for strings and lists and so on. It changes the lhs in
place appending the rhs. In this case the
Fuzzyman <[EMAIL PROTECTED]> wrote:
> What gives ?
...
> >>> a = []
> >>> def f():
> return a
...
> >>> f() += [4]
> SyntaxError: can't assign to function call
Exactly what the error message says: it's syntactically forbidden to
perform any assignment on a function-call.
If you're ke
What gives ?
>>> a = []
>>> def f():
return a
>>> f()
[]
>>> a.append(3)
>>> f()
[3]
>>> a += [3]
>>> a
[3, 3]
>>> f()
[3, 3]
>>> f() += [4]
SyntaxError: can't assign to function call
>>>
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
--
http://mail.python.org/mailman/listinf
PyOpenGL comes with a Tkinter widget for OpenGL, and searching google
"wxwidgets opengl" yields http://www.wxwidgets.org/opengl.htm
Kind regards,
Karsten.
--
http://mail.python.org/mailman/listinfo/python-list
Steve Juranich wrote:
> IMHO, __slots__ is unpythonic. Many others have stated so on the
> list. That's why it's great that you're free to ignore that variable.
> I suggest that you do so (as I have chosen to do). I'm sure that
> there are situations where you *MUST* have this kind of capability
> I mean what I really would like is to have something C++ - like "for
> (int idx = a; idx < b; i++) { .. }" where no internal vector or
> something like that is allocated but only a few op's on registers are
> performed; in the whileloop in python the picture is roughly the same
Use xrange i
I think that the classification has some meaning, even if of course any
language has different shades of both sides. I'd say that with python
is difficult to choose one of the two categories because it's good both
as a pratical language and as a mind-opener language.
IMO another language that woul
Hi Ross.
Thanks a lot for your clarifying. I didn't think my post could be an
Unicode frame.
I don't know this mailing list is the right place talking about
Unicode issue, but as for me, a million codespace which UTF-16 brings
is not enough. It presume that same characters has a same codepoint
I've been combing google for the past week trying to find an
appropriate set of tools for a project I'm working on. Simply put,
what I need is a GUI, powered by python, (I really don't want to touch
any C++ code at all), that has an openGL canvas/scene(?), with a python
interpreter sitting beside
Steve Juranich wrote:
> Gerard Flanagan wrote:
>
> > Hello all
> >
> > Could anyone shed any light on the following Exception? The code which
> > caused it is below. Uncommenting the 'super' call in 'XmlNode' gives
> > the same error. If I make XmlNode a subclass of 'object' rather than
> > 'list
Don Taylor wrote:
> I am puzzled about the following piece of code which attempts to create
> a class that can be used as record or struct with a limited set of
> allowed attributes that can be set into an instance of the class.
>
> I don't understand why I cannot set an attribute 'age' into reco
Gerard Flanagan wrote:
> Hello all
>
> Could anyone shed any light on the following Exception? The code which
> caused it is below. Uncommenting the 'super' call in 'XmlNode' gives
> the same error. If I make XmlNode a subclass of 'object' rather than
> 'list' then the code will run.
...
> Code:
Writing a while loop with ++x to increment the index was the first
mistake i made with python.
"++x" unfortunately is valid, it's not a single operator but a double
"unary plus"
Andrea
--
http://mail.python.org/mailman/listinfo/python-list
Steven is right, however, there is a way:
def new_record(slotlist):
class R(object):
__slots__ = slotlist
return R()
record1 = new_record(["age", "name", "job"])
record1.age = 27
record1.name = 'Fred'
record1.job = 'Plumber'
record1.salary = 5
--
http://mail.python.org/mailman/listi
Trying to get my feet wet with wxPython (moving from just
command-line apps), I tried the obvious (or, at least to me
was obvious):
Start python, "import wx" and then do a "help(wx)" to see
what it can tell me.
Unfortunately, it spewed back a handful of errors, gasped,
wheezed and died semi-h
On Sun, 26 Feb 2006 17:01:45 -0500, Don Taylor wrote:
> Hi:
>
> I am puzzled about the following piece of code which attempts to create
> a class that can be used as record or struct with a limited set of
> allowed attributes that can be set into an instance of the class.
>
> class RecordClass
kmkz wrote:
> I have a program A that forks off two other programs, B and C. I need B
> and C to both terminate if A is closed, but by using the
> subprocess.call() method this seems to not be the case; I can shut down
> the "black box" that is program A and B/C will still stay up.
>
> How can I
Hello all
Could anyone shed any light on the following Exception? The code which
caused it is below. Uncommenting the 'super' call in 'XmlNode' gives
the same error. If I make XmlNode a subclass of 'object' rather than
'list' then the code will run.
Thanks in advance.
Exception:
Traceback (mos
On Sun, 26 Feb 2006 21:58:30 +0100, Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
>> Can you please tell me what is the meaning of
>> UnboundLocalError: local variable 'colorIndex' referenced before
>> assignment
>>
>> in general?
>
> Well, pretty much of what it says: You tried to acce
On Sun, 26 Feb 2006 12:48:47 -0800, Crutcher wrote:
> My central thesis: you are using a poor understanding of language to
> classify languages into things you understand (tool languages) and
> things which _you_ find 'deep' (and difficult to learn), which you call
> 'Zen languages'. This is ridic
Which one is better w.r.t. memory allocation but also w.r.t. speed:
## 1.1 ##
def forloop(a,b):
for idx in range(a,b):
## ..
## do something
## ..
## 1.2 ##
def whileloop(a,b):
idx = a
while idx < b:
## ..
Hi:
I am puzzled about the following piece of code which attempts to create
a class that can be used as record or struct with a limited set of
allowed attributes that can be set into an instance of the class.
class RecordClass(object):
__slots__ = ["foo"]
def __init__(self, args):
* Bob ([EMAIL PROTECTED]) wrote:
> I'd like to setup command line switches that are dependent on other
> switches, similar to what rpm does listed below. From the grammar below
> we see that the "query-options" are dependent on the query switch,
> {-q|--query}. Can "optparse" do this or do I have t
On Sunday 26 February 2006 22:44, [EMAIL PROTECTED] wrote:
> I am new to python, can you please tell me how can I convert my python
> script into an executable on linux?
> i.e. instead of typing 'python myscript.py abc', I just need to do
> 'myscript.py abc'?
Use the shebang syntax. Use this as a
[EMAIL PROTECTED] schrieb:
> I am new to python, can you please tell me how can I convert my python
> script into an executable on linux?
> i.e. instead of typing 'python myscript.py abc', I just need to do
> 'myscript.py abc'?
> and how can I get the input argument from my script , in my example,
>It's faster on my system because d.keys() is already sorted. But that may not
>be the case on other versions of python.<
In my version it's a little slower. But what system are you using where
keys is already sorted? IronPython maybe?
Bye,
bearophile
--
http://mail.python.org/mailman/listinf
Hi,
I have a program A that forks off two other programs, B and C. I need B
and C to both terminate if A is closed, but by using the
subprocess.call() method this seems to not be the case; I can shut down
the "black box" that is program A and B/C will still stay up.
How can I achieve the desired
Alex Martelli wrote:
> Crutcher <[EMAIL PROTECTED]> wrote:
>...
>
>>No, I don't disagree that people do this. The history of "Zen and the
>>Art of X" dates from "Zen and the Art of Motorcycle Repair", which is
>
>
> That's Maintenance, not Repair. Subtle but important distinction.
>
Since
I am new to python, can you please tell me how can I convert my python
script into an executable on linux?
i.e. instead of typing 'python myscript.py abc', I just need to do
'myscript.py abc'?
and how can I get the input argument from my script , in my example,
how can I read 'abc'?
Thank you.
--
Ron Adam <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Your solution Steven Bethard looks very intelligent, here is a small
> > speed test, because sorting a list according another one is a quite
> > common operation.
> > (Not all solutions are really the same, as Alex has shown).
>
>
On Sun, 26 Feb 2006 11:55:54 -0800, Allerdyce.John wrote:
> Do I need to convert string to integer in python? or it will do it for
> me (since dynamic type)?
>
> In my python script, I have this line:
> x /= 10;
>
> when i run it, I get this error:
> TypeError: unsupported operand type(s) fo
[EMAIL PROTECTED] wrote:
> Your solution Steven Bethard looks very intelligent, here is a small
> speed test, because sorting a list according another one is a quite
> common operation.
> (Not all solutions are really the same, as Alex has shown).
Try this one.
def psort10(s1, s2):
d = dict
Crutcher <[EMAIL PROTECTED]> wrote:
...
> No, I don't disagree that people do this. The history of "Zen and the
> Art of X" dates from "Zen and the Art of Motorcycle Repair", which is
That's Maintenance, not Repair. Subtle but important distinction.
Alex
--
http://mail.python.org/mailman/li
[EMAIL PROTECTED] schrieb:
> Can you please tell me what is the meaning this error in general?
>
> UnboundLocalError: local variable 'colorIndex' referenced before
> assignment
>
> In my python script,
> I have a variable define and init to 0, like this
> colorIndex = 0
>
> and in one of my fu
[EMAIL PROTECTED] writes:
> When I try your idea, I have this error
>
> x, y, width, height = re.findall(pattern, str)[0]
> IndexError: list index out of range
>
> How can I use findall to handle error case? i.e. what if there is no
> match? how can I handle it gracefully?
This is explained i
Crutcher wrote:
> I've tossed it to python-dev, but how do I submit it to the cookbook?
http://aspn.activestate.com/ASPN/Python/Cookbook/
I think it is a good place to stay accessible even if python-dev
overlooks it.
Kay
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote in news:1140987642.195734.187540
@t39g2000cwt.googlegroups.com:
> Can you please tell me what is the meaning this error in general?
>
> UnboundLocalError: local variable 'colorIndex' referenced before
> assignment
>
> In my python script,
> I have a variable define and i
Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
>
>> okay, I try you suggestion, and re-write my code like this:
>> colors = ["#ff", "#00FF00", "#FF"]
>> colorIndex = 0
>>
>> def getText(nodelist):
>>
>>
>> for str in strings:
>>
>> print colors[color
Can you please tell me what is the meaning this error in general?
UnboundLocalError: local variable 'colorIndex' referenced before
assignment
In my python script,
I have a variable define and init to 0, like this
colorIndex = 0
and in one of my functions, I increment it by 1
def myFunc
co
[EMAIL PROTECTED] schrieb:
> Can you please tell me what is the meaning of
> UnboundLocalError: local variable 'colorIndex' referenced before
> assignment
>
> in general?
Well, pretty much of what it says: You tried to access a variable without prior
assignment to it. Like this:
a = b**2 + c
Can you please tell me what is the meaning of
UnboundLocalError: local variable 'colorIndex' referenced before
assignment
in general?
--
http://mail.python.org/mailman/listinfo/python-list
I've tossed it to python-dev, but how do I submit it to the cookbook?
--
http://mail.python.org/mailman/listinfo/python-list
> My point is simply that, for some languages L,
> "Zen and the art of L" or "The Tao of L" are plausible
> titles ("Zen and the Art of Lisp Programming" would be plausible) but
> for some languages they wouldn't ("The Tao of Fortran" ?)
> Do you disagree?
No, I don't disagree that people do this.
Crutcher wrote:
> This is fun :)
> {Note: I take no responsibilty for anyone who uses this in production
> code}
>
> #!/usr/bin/env python2.4
> # This program shows off a python decorator
> # which implements tail call optimization. It
> # does this by throwing an exception if it is
> # it's own g
[EMAIL PROTECTED] schrieb:
> okay, I try you suggestion, and re-write my code like this:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0
>
> def getText(nodelist):
>
>
> for str in strings:
>
> print colors[colorIndex % colors.length]
>
[EMAIL PROTECTED] schrieb:
> Do I need to convert string to integer in python? or it will do it for
> me (since dynamic type)?
>
> In my python script, I have this line:
> x /= 10;
>
> when i run it, I get this error:
> TypeError: unsupported operand type(s) for /=: 'unicode' and 'int'
>
> I
okay, I try you suggestion, and re-write my code like this:
colors = ["#ff", "#00FF00", "#FF"]
colorIndex = 0
def getText(nodelist):
for str in strings:
print colors[colorIndex % colors.length]
colorIndex += 1
but i get this error
[EMAIL PROTECTED] wrote:
> I have a string array:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0;
>
> and I want to loop thru each element of colors
>
> for str in strings:
> print colors[colorIndex++ % colors.length]
>
>
> But i get an invalid syntax error when I execute the s
[EMAIL PROTECTED] schrieb:
> I have a string array:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0;
>
> and I want to loop thru each element of colors
>
> for str in strings:
> print colors[colorIndex++ % colors.length]
>
>
> But i get an invalid syntax error when I execute the
Zajcev Evgeny <[EMAIL PROTECTED]> wrote:
...
> > The following will work, and probably only be twice as slow as
> > 'isalpha' :-) :
> >
> > def alfa(w):
> >return w.replace('_', '').isalpha()
>
> Yeah, great performance indeed, thanks!
Except it rejects a w that's JUST an underscore, whil
[EMAIL PROTECTED] schrieb:
> Do I need to convert string to integer in python? or it will do it for
> me (since dynamic type)?
>
> In my python script, I have this line:
> x /= 10;
>
> when i run it, I get this error:
> TypeError: unsupported operand type(s) for /=: 'unicode' and 'int'
>
> I
<[EMAIL PROTECTED]> wrote:
> Do I need to convert string to integer in python? or it will do it for
> me (since dynamic type)?
Nope, no such implicit conversion (thanks be!). Strings are strings and
ints and ints and never the twain shall meet, except by explicit
request;-).
> In my python scri
<[EMAIL PROTECTED]> wrote:
> I am using the print function in my python script.
> Can you please tell me what can I do to redirect the output to an file?
f = open('aaargh', 'w')
print>>f, 'killew wabbit'
Alex
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 148 matches
Mail list logo