Hi,
t = (1, (2, 3))
I am bit suprised, that I cannot access '3' via:
t[1].[1] # syntax error
But t[1].__getitem__(1) works like expected.
Why is that?
Regards
Georg Sauthoff 3 1920
t = (1, (2, 3))
>
I am bit suprised, that I cannot access '3' via:
t[1].[1] # syntax error
But t[1].__getitem__(1) works like expected.
Why is that?
What is "t"? It's a tuple. A tuple can be indexed, or you can
call its __getitem__ method. Thus, the one-th element of t is either
t[1]
or
t.__getitem__(1 )
You're asking for the sub-element of that thing just returned.
Thus, you either need to use
t[1][1]
or
t[1]._getitem(1)
or
t.__getitem__(1 )[1]
or
t.__getitem__(1 ).__getitem__(1 )
Imagine that you used
x = t[1]
You wouldn't use
x.[1]
you'd use
x[1]
or
x.__getitem__(1 )
Same thing. As simple as search-and-replace of "t[1]" with "x"
-tkc
Hi Georg!
In [1]: t=(1,(2,3))
I am bit suprised, that I cannot access '3' via:
t[1].[1] # syntax error
But t[1].__getitem__(1) works like expected.
In [2]: k=t[1]
In [3]: k[1]
Out[3]: 3
In [4]: t[1][1]
Out[4]: 3
In [5]: k.__getitem__(1 )
Out[5]: 3
In [6]: k.[1]
------------------------------------------------------------
File "<ipython console>", line 1
k.[1]
^
SyntaxError: invalid syntax
Note that:
In [7]: type(t[1])
Out[7]: <type 'tuple'>
just as t.
hth,
jss
On 2006-09-04, Tim Chase <py*********@ti m.thechases.com wrote:
Hi,
[nested tuples]
thanks - I should not post before 8 am or 10 pm ...
Regards
Georg Sauthoff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: omission9 |
last post by:
I have a dictionary that looks like this
MY_DICT=FOO
I am having a problem updating this with a simple
MY_DICT.update(NEW_DICT) as update doesn't seem to care about getting
into the inner dicts.
Getting the keys of each and iterating through and updating each one is
terribly slow as the number of keys gets bigger and bigger.
What is the bst way to update my nested dicts?
|
by: Nickolay Kolev |
last post by:
Hi all,
I have a list whose length is a multiple of 3. I want to get a list of
tuples each of which has 3 consecutive elements from the original list,
thus packing the list into smaller packets. Like this:
l =
tups =
|
by: Markus Ernst |
last post by:
Hi
I have a validation problem with a form and nested divs. I understand what
the problem is, but I don't see how to fix it. This is my normal page
structure, and it validates:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
|
by: Luis P. Mendes |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I'm trying to solve this problem:
suppose I'm reading a csv file and want to create a tuple of all those
rows and values, like ((row1value1, row1value2, row1value3),(row2value1,
row2value2, row2value3),..., (rowNvalue1, rowNvalue2, rowNvalue3))
|
by: ZikO |
last post by:
Hi there.
I have a problem. I have created nested classes but don't know how to access to
inner classes. I know I can create objects:
Hen Object;
Hen::Nest ObjectNest;
Hen::Nest::Egg ObjectEgg;
and have access to particular elements
| |
by: =?Utf-8?B?SmVyZW15X0I=?= |
last post by:
I am working on an order entry program and have a question related to
deserializing nodes with nested elements.
The purchase order contains multiple line items which I select using an
XmlNodeList. I am trying to deserialize the nodes using a foreach as follows:
foreach(XmlNode lineItem in LineItemsNodeList)
An abbreviated example of the nested lineItem node looks like this:
|
by: jubelbrus |
last post by:
Hi
I'm trying to do the following.
#include <vector>
#include <boost/thread/mutex.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp>
class {
|
by: Henrik Bechmann |
last post by:
All,
I'm trying to spoof Google's vertical tabs in a vertical menu
structured with nested UL/LI elements.
To do this, I need to find out where the anchor in the LI is, and then
create an absolute positioned div to bridge the space between the menu
and the content page.
This works with one level of LI's. However, with more than one, the
|
by: Prisoner at War |
last post by:
Actually, it doesn't have to be a blockquote...but I'm at my wits'
end: I want to make bold several lines of text which have a pair of
<br /tags between them...seems like the <b></bdo not "carry over"
when there are <br /tags involved...???
I've tried using <p style="font-weight: bold;"></p>, I've tried
<blockquote></blockquote>...I just can't figure how I'm supposed to
get the <b></btags to work for all the lines! Surely there must be...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |