Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106951 > unrolled thread
| Started by | salma ammar <ammarsalma118@gmail.com> |
|---|---|
| First post | 2016-04-13 16:53 +0100 |
| Last post | 2016-04-13 16:02 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
IdentationError; unexpected indent salma ammar <ammarsalma118@gmail.com> - 2016-04-13 16:53 +0100
Re: IdentationError; unexpected indent Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-13 16:02 +0000
| From | salma ammar <ammarsalma118@gmail.com> |
|---|---|
| Date | 2016-04-13 16:53 +0100 |
| Subject | IdentationError; unexpected indent |
| Message-ID | <mailman.79.1460562813.15650.python-list@python.org> |
Hi,
I am about to run this code using python 2.7. But when executing this code,
an error appears (see attachement): IdentationError; unexpected indent
What should I rectify to correct this error please?
*import sys*
*sys.path.append('C:/Users/user/src/sumo-0.22.0/tools')*
*import sumolib*
*net =
sumolib.net.readNet("C:/Users/user/src/sumo-0.22.0/tools/sumolib/net/qgislyonvelo.net.xml")*
*radius = 0*
*f = open("C:/fichierstations.txt", "r")*
*contenu = f.read()*
*print(contenu)*
*for id, lat, lon in f:*
* x, y = net.convertLonLat2XY(lon, lat)*
* print(x, y)*
* edges = net.getNeighboringEdges(x, y, radius)*
* print (edges)*
* while len(edges) == 0:*
* radius = radius + 10*
* edges = net.getNeighboringEdges(x, y, radius)*
* distancesAndEdges = sorted([(dist, edge) for edge, dist in edges])*
* print(distancesAndEdges)*
* edgeofstation[id] = distancesAndEdges[0]*
* print (edgeofstation[id])*
*f.close()*
Thank you in advance.
[toc] | [next] | [standalone]
| From | Rob Gaddi <rgaddi@highlandtechnology.invalid> |
|---|---|
| Date | 2016-04-13 16:02 +0000 |
| Message-ID | <nelqja$oir$1@dont-email.me> |
| In reply to | #106951 |
salma ammar wrote:
> Hi,
>
> I am about to run this code using python 2.7. But when executing this code,
> an error appears (see attachement): IdentationError; unexpected indent
>
> What should I rectify to correct this error please?
>
>
> *import sys*
> *sys.path.append('C:/Users/user/src/sumo-0.22.0/tools')*
> *import sumolib*
> *net =
> sumolib.net.readNet("C:/Users/user/src/sumo-0.22.0/tools/sumolib/net/qgislyonvelo.net.xml")*
> *radius = 0*
> *f = open("C:/fichierstations.txt", "r")*
>
> *contenu = f.read()*
>
> *print(contenu)*
> *for id, lat, lon in f:*
> * x, y = net.convertLonLat2XY(lon, lat)*
> * print(x, y)*
> * edges = net.getNeighboringEdges(x, y, radius)*
> * print (edges)*
> * while len(edges) == 0:*
> * radius = radius + 10*
> * edges = net.getNeighboringEdges(x, y, radius)*
> * distancesAndEdges = sorted([(dist, edge) for edge, dist in edges])*
> * print(distancesAndEdges)*
> * edgeofstation[id] = distancesAndEdges[0]*
> * print (edgeofstation[id])*
> *f.close()*
>
>
> Thank you in advance.
Offhand, I'd say you should fix the error in your indentation, probably
at the line number that the error specifies.
Python cares about indentation, and uses it the way other languages use
braces. Things that are at the same logical depth must be indented the
same way. That includes the difference between tabs and spaces, which
you should NEVER EVER EVER mix and match.
--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web