On 2007-09-27, Steve Holden <[EMAIL PROTECTED]> wrote:
> Self-evidently you are *not* creating the variables you think you are in
> the variablePage module. Have you tried an interactive test? Try this at
> the interpreter prompt:
>
> >>> import variablePage
> >>> dir(variablePage)
>
> and you wil
I'm stymied by what should be a simple Python task: accessing the value of
a variable assigned in one module from within a second module. I wonder if
someone here can help clarify my thinking. I've re-read Chapter 16 (Module
Basics) in Lutz and Ascher's "Learning Python" but it's not working for
Haven't found an answer to my question in the books and other docs I have
available, so I am asking here.
I have three lists of data retrieved from database tables. I want to cycle
through all three lists using nested FOR loops. What is the behavior if
there are no data in the list used in the
On 2007-02-28, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
import itertools
tuple(itertools.chain((t[0], t2[0].encode('ascii')), t[2:]))
> ('eco', 'Roads', 0.073969887301348305)
Steven,
As suggested in the previous article, I handled it where the values are
read from the list retrie
I'm a bit embarrassed to have to ask for help on this, but I'm not finding
the solution in the docs I have here.
Data are assembled for writing to a database table. A representative tuple
looks like this:
('eco', "(u'Roads',)", 0.073969887301348305)
Pysqlite doesn't like the format of the mi
On 2007-02-28, Robert Kern <[EMAIL PROTECTED]> wrote:
> No, that's a numpy array.
Robert,
That's where I went off. I forgot that I'm still dealing with a 1D NumPy
array and not a list. No wonder I had such fits!
> Those aren't tuples, but complex numbers.
I have not seen the 'j' suffix bef
While it should be easy for me to get what I need from a list, it's
proving to be more difficult than I expected.
I start with this list:
[ 6.24249034e-01+0.j 5.11335982e-01+0.j 3.67333773e-01+0.j
3.01189122e-01+0.j 2.43449050e-01+0.j 1.82948476e-01+0.j
1.43655139e-01+0.j 9.9
On 2007-02-27, Leif K-Brooks <[EMAIL PROTECTED]> wrote:
Lief, Bjoern:
> l = l[0]
Of course! If I had let it work in my mind overnight I would almost
certainly have seen this.
Thank you both for your patient responses,
Rich
--
http://mail.python.org/mailman/listinfo/python-list
I start with a list of tuples retrieved from a database table. These
tuples are extracted and put into individual lists. So I have lists that
look like this: [1, 2, 3, 4, 5]. When I concatenate lists, I end up with a
list of lists that looks like this: [[1, 2, 3. 4, 5]. [6, 7. 8, 9. 10]].
Then, I
On 2007-02-25, Jussi Salmela <[EMAIL PROTECTED]> wrote:
> I'm nitpicking, but the OP has a list of tuples:
> ec = [ item[2:] for item in mainlist if item[:2] == ('eco','con') ]
Jussi,
An excellent nit to pick.
Thank you,
Rich
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-02-25, Paddy <[EMAIL PROTECTED]> wrote:
> You might also use list comprehensions to accumulate the values you
> need:
>
> ec = [ item[2:] for item in mainlist if item[:2] == ['eco','con'] ]
Thank you, Paddy. That's the syntax I couldn't work out myself.
Rich
--
http://mail.python.or
On 2007-02-25, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> Item is ALREADY the "current" tuple...
>
> for tpl in mainlist:
> if tpl[0] == "eco" and tpl[1] == "con":
> ec.Append(tpl[2:]) #presuming ec is NOT a list, as Append()
>
While working with lists of tuples is probably very common, none of my
five Python books or a Google search tell me how to refer to specific items
in each tuple. I find references to sorting a list of tuples, but not
extracting tuples based on their content.
In my case, I have a list of 9 tupl
On 2007-02-10, James Stroud <[EMAIL PROTECTED]> wrote:
> Assuming item is "(u'ground water',)"
>
> import re
> item = re.compile(r"\(u'([^']*)',\)").search(item).group(1)
James,
I solved the problem when some experimentation reminded me that 'item' is
a list index and not a string variable. by
On 2007-02-10, [EMAIL PROTECTED] wrote:
> if item == selName:
Slicing doesn't seem to do anything -- if I've done it correctly. I
changed the above to read,
if item[2:-2] == selName:
but the output's the same.
Rich
--
http://mail.python.org/mailman/listinfo/python-list
I'm not sure how to change a string so that it matches another one.
My application (using wxPython and SQLite3 via pysqlite2) needs to compare
a string selected from the database into a list of tuples with another
string selected in a display widget.
An extract of the relevant code is:
On 2007-02-08, Paul Rubin wrote:
> [EMAIL PROTECTED] writes:
>> if cond1:
>> if cond2:
>> do_something.
>
> You can write:
>if cond1 and cond2:
> do_something
>
>> if cond1 OR if cond2:
>> do_something.
>
> if cond1 or cond2:
>do_something
>
>
All my python books and references I find on the web have simplistic
examples of the IF conditional. A few also provide examples of multiple
conditions that are ANDed; e.g.,
if cond1:
if cond2:
do_something.
However, I cannot find, nor create by trial-and-er
My editor is emacs in linux, and I have the python mode enabled. The two
menus -- IM-Python and Python -- allow me to navigate within the loaded
module and open execute buffers, among other things. But, I don't see a way
to run a wxPython application from within the editor as I would from the
com
On 2006-01-08, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> DATA_MAP = {
> chr(32)+chr(32): 0,
> chr(36)+chr(32): "natural",
> ...
> chr(32)+chr(1): 5,
> chr(66)+chr(32): 0.167,
> }
> ...
> row_value = DATA_MAP[source.read(2)]
>
> # or: row_value = DATA_MAP.get(source.read(2), DE
I need to look at two-byte pairs coming from a machine, and interpret the
meaning based on the relative values of the two bytes. In C I'd use a switch
statement. Python doesn't have such a branching statement. I have 21
comparisons to make, and that many if/elif/else statements is clunky and
inef
21 matches
Mail list logo