Finding Default Page Name using urllib2

2008-10-27 Thread barrett
Is there a way to find the name of a page you are retrieving using
python.  For example, if I get http://www.cnn.com/ i want to know that
the page is index.html.  I can do this using wget. as seen in the code
below.  Can I do this in python?

Thanks,

$ wget cnn.com
--11:15:25--  http://cnn.com/
   => `index.html'
Resolving cnn.com... 157.166.226.25, 157.166.226.26,
157.166.224.25, ...
Connecting to cnn.com|157.166.226.25|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.cnn.com/ [following]
--11:15:25--  http://www.cnn.com/
   => `index.html'
Resolving www.cnn.com... 157.166.224.25, 157.166.224.26,
157.166.226.25, ...
Reusing existing connection to cnn.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 96,094 (94K) [text/html]

100%[>] 96,09468.15K/s

11:15:28 (67.99 KB/s) - `index.html' saved [96094/96094]
--
http://mail.python.org/mailman/listinfo/python-list


PLEASE HELP--Button images refuse to show.

2010-04-19 Thread Barrett
I have been fighting the same bug for weeks now with zero success: I
am trying to get images to come up on my buttons, but they are way too
small. Regardless of whether I used my old Python 2.5.1 or now 2.6.5,
the following code:


'''Minesweeper.'''

from Tkinter import *
#from PIL import Image
import Tkinter as tk
#import PIL as pil
import random
#import glob, os

BEGINNER = 1
INTERMEDIATE = 2
EXPERT = 3

OFFSET = 2

BUTTON_SIZE = 2

class Board(Frame, object):
def __init__(self, master, difficulty, photo):
Frame.__init__(self, master)
if difficulty == BEGINNER:
self.x = 9
self.y = 9
self.mines = 10
elif difficulty == INTERMEDIATE:
self.x = 16
self.y = 16
self.mines = 40
elif difficulty == EXPERT:
self.x = 30
self.y = 16
self.mines = 99

self.grid()
self.photo = photo
self.create_widgets()

def create_widgets(self):
#Create the grid.
self.square = []
self.isAMine = []
self.selected = []
for i in range(self.x):
squareColumn = []
mineColumn = []
selectedColumn = []
for j in range(self.y):
squareColumn.append(Button(self, width = 3, height =
2,\
   padx = -1, pady = -1))
squareColumn[j].grid(row = j + OFFSET, column = i)
mineColumn.append(False)
selectedColumn.append(False)
self.square.append(squareColumn)
self.isAMine.append(mineColumn)
self.selected.append(selectedColumn)

#Plant the mines.
print 'Dimensions:', self.x, self.y
for i in range(self.mines):
mineSquare = random.randrange(self.x * self.y)
mine_y = mineSquare / self.x
mine_x = mineSquare % self.x
self.isAMine[mine_x][mine_y] = True
self.square[mine_x][mine_y]['text'] = 'X' #temp line;
shows mines
#photo = tk.PhotoImage(file="1.gif")
#self.square[mine_x][mine_y]['image'] = photo #temp line;
shows mines


for i in range(self.y):
for j in range(self.x):
self.square[j][i]['command'] = lambda x=j, y=i:
self.hit(x, y)

#Runs when a button (square) is clicked.
def hit(self, x, y):
self.selected[x][y] = True
self.square[x][y].config(relief=SUNKEN)

#print x, y
if self.isAMine[x][y]:
print 'Mine found.  Location:', x, y
else:
#Look at all eight neighbors and see if they are mines.
#x>0, etc. avoid looking off the edge of the map.
adjMines = 0
if (x > 0 and y > 0) and self.isAMine[x-1][y-1]: #NW
adjMines+=1
if y > 0 and self.isAMine[x][y-1]: #N
adjMines+=1
if (x < self.x-1 and y > 0) and self.isAMine[x+1][y-1]:
#NE
adjMines+=1
if x > 0 and self.isAMine[x-1][y]: #W
adjMines+=1
if x < self.x-1 and self.isAMine[x+1][y]: #E
adjMines+=1
if (x > 0 and y < self.y-1) and self.isAMine[x-1][y+1]:
#SW
adjMines+=1
if y < self.y-1 and self.isAMine[x][y+1]: #S
adjMines+=1
if (x < self.x-1 and y < self.y-1) and\
   self.isAMine[x+1][y+1]: #SE
adjMines+=1

if adjMines != 0 and adjMines < 3:
self.square[x][y]['text'] = ''
self.square[x][y]['image'] = self.photo[adjMines]

elif adjMines>0: #temp line until the pix are ready
self.square[x][y]['text'] = adjMines

else: #adjMines == 0
#If none of the adjacent squares have mines, it is
safe to hit
#them all.  Just like the official game, this game
does
#precisely that.
if (x > 0 and y > 0) and not self.selected[x-1][y-1]:
Board.hit(self, x-1, y-1) #NW
if y > 0 and not self.selected[x][y-1]: #N
Board.hit(self, x, y-1)
if (x < self.x-1 and y > 0) and not self.selected[x+1]
[y-1]: #NE
Board.hit(self, x+1, y-1)
if x > 0 and not self.selected[x-1][y]: #W
Board.hit(self, x-1, y)
if x < self.x-1 and not self.selected[x+1][y]: #E
Board.hit(self, x+1, y)
if (x > 0 and y < self.y-1) and not self.selected[x-1]
[y+1]: #SW
Board.hit(self, x-1, y+1)
if y < self.y-1 and not self.selected[x][y+1]: #S
Board.hit(self, x, y+1)
if (x < self.x-1 and y < self.y-1) and\
   not self.selected[x+1][y+1]:
Board.hit(self, x+1, y+1) #SE

sel

Re: What is Expresiveness in a Computer Language?

2005-07-10 Thread Pete Barrett
On 10 Jul 2005 02:57:04 -0700, "Xah Lee" <[EMAIL PROTECTED]> wrote:

>Similarly, in computer languages, expressiveness is significant with
>respect to semantics, not syntactical variation.
>
It may just be me, but I tend to think of a computer language as a
tool for directing computers to perform specific actions. Do we talk
about the expressiveness of a spade?

There's a similar concept in the 'possible uses' of a tool (a spade is
an excellent tool for digging the garden, but you wouldn't use it to
clean your teeth; you *could* use a toothbrush to dig the garden, but
you wouldn't if a spade was available). Similarly with computer
languages - some are better for certain tasks than others, but I don't
think 'expressiveness' is the way to describe that.

Pete Barrett
-- 
http://mail.python.org/mailman/listinfo/python-list


with ignored

2013-04-07 Thread Barrett Lewis
I was recently watching that Raymond Hettinger video on creating Beautiful
Python from this years PyCon.
He mentioned pushing up the new idiom

with ignored():
 # do some work

I tracked down his commit here http://hg.python.org/cpython/rev/406b47c64480

But am unsure how the yield works in the given situation.

I know about creating generators with yield and have read the docs on how
it maintains state.

I think it works because it is returning control back to the caller
while maintaining the try so if the caller throws it is caught by the
context. Is this correct? I would love an in depth explanation of how this
is working. I am trying to learn as much as possible about the actual
python internals.

Thanks in advance!
-Barrett
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: with ignored

2013-04-07 Thread Barrett Lewis
>
> However, ignored() is actually implemented as a generator function
>
with the @contextmanager decorator shortcut.  This decorator takes a
> generator function and wraps it up as a class with the necessary
> __enter__ and __exit__ methods.  The __enter__ method in this case
> calls the .next() method of the generator and returns after it yields
> once.


I looked up the source to the decorator
found here:http://hg.python.org/cpython/file/406b47c64480/Lib/contextlib.py for
anyone interested.
It appears that they are using yield so that they can call it again and
force it to throw the stop iteration exception.



> The __exit__ method calls it again -- or it calls the .throw()
> method if an exception was passed in -- and expects the generator to
> exit as a result.
>
>
And here to go with what I said above, they want to be able to use the
generators throw ability to capture any exception and throw it to the
generator, but then why do they *need* the generator to not iterate again?
Or in other words, why when they create the context manager via
_GeneratorContextManager on line 33, is there the clause in __exit__ to
have stop iteration happen or else throw a runtime error?

I am thinking this is because it needs the yield to be over so that it can
return the control flow to normal, and that subroutine will be done. But I
am new to the whole subroutine paradigm so I could be misunderstanding
this.

Also, if the value was none, why are they instantiating a new exception
with value = type()? How could there be a type for the exception without
the exception? (From what I understand type is the error type, and value is
the error object).


So from the perspective of the generator it does its context setup (in
> this case, setting up a try block) prior to the yield, and then does
> the cleanup (in this case, selectively catching and suppressing the
> exceptions) after the yield.
>
This part makes sense logically. And I like the simplicity. Now I just need
to make sure I understand how the yield semantics are allowing this
construct to work.

Thanks for the reply Ian!

> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Formatting lost in hg-web (was Re: with ignored)

2013-04-08 Thread Barrett Lewis
I am viewing it on Chrome Version 26.0.1410.43 m for windows and it works
perfectly for me.


On Mon, Apr 8, 2013 at 12:32 AM, Chris Angelico  wrote:

> On Mon, Apr 8, 2013 at 4:38 PM, Barrett Lewis 
> wrote:
> > I looked up the source to the decorator
> > found here:
> http://hg.python.org/cpython/file/406b47c64480/Lib/contextlib.py
> > for anyone interested.
>
> Strangely, line indentation seems to be swallowed in the web view of
> the Mercurial tree. The code directly follows the line numbers, so it
> goes ragged between (eg) lines 9 and 10. Is this a browser bug? I
> tried on Chrome 26.0.1410.40 and Firefox 19.0.2 on Windows.
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to do a Lispy-esque read?

2013-04-08 Thread Barrett Lewis
> For example, if the input stream contained the text:
> [1, # python should ignore this comment
> 2]
>
> and I do a "read" on it, I should obtain the result
> [1, 2]
> --
>

I don't know much about lisp but given that input and the desired output
you can write functions like the following

def strtolist(l):
if l.startswith('['):
l = l[1:]
if l.endswith(']'):
l = l[:-1]

# treat newlines as if they are commas so we can easily split
l = l.replace('\n', ',').split(',')
# list comprehension
# strip to remove whitespace and aggregate all elements without the
comment
# you can further refine this to create ints by using the int() method
return [x for x in l if not x.strip().startswith('#')]

you would have to use input() to read the input or open a file. Either way
you can pass that value to strtolist and it will convert it to a list of
strings.
However, this implementation is not very robust and doesn't cover a lot of
edge cases (more a demo of how it might be done, I don't know your python
experience so forgive me if this is all self evident).

The real solution that I would use would be to use the json module.
Docs: http://docs.python.org/3.3/library/json.html
It allows you to take a string and turn it into a native dict or list in
python. The great part is that it is fairly robust and it has a simple
interface. You could take input() and send it to loads and it will return
an array. The downside is json doesn't allow comments.

If you really want comments, you could look into some of the yaml
libraries, a quick google search shoes PyYaml is out there. I however don't
have any knowledge of that module or other yaml modules as I find json is
enough for anything I've ever attempted.

I hope that helps
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: help needed

2013-04-08 Thread Barrett Lewis
Do you happen to be on windows? Because if you are then you need to edit
the registry. If you are on windows let me know and I will walk you through
the fix, but if not then it would be a waste of time for me to explain it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
>   d = {}
>   for key, d[key] in (("this",18), ("that",17), ("other",38)):
> print key
> do_something(d)
>

Why not use a dict comprehension?
d = {k:v for k,v in  (("this",18), ("that",17), ("other",38))}

I feel this is more straightforward and easier to read. the results are the
same however.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Process tuple contents on the fly

2013-04-15 Thread Barrett Lewis
> In the particular case I did it in, I needed the incremental results
> passed to a function, not just the final result.  I don't think this
> made it into the final code, rather it was expanded to be more
> readable.  But the discovery made me feel a disturbance in the
> Pythonic force of the universe. :*)
>
> -tkc
>

I see what you are saying, but I agree that is a disturbance I didn't even
know you could do
for key, d[key], that just feels like bad news. however for what you are
saying it makes sense. TIL that you can use an unpacked value during
unpacking!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a jet fuel/hydrocarbon fire collapse a steel structure? An experiment.

2007-02-02 Thread John Barrett

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>> >>Can a jet fuel/hydrocarbon fire collapse a steel structure? An
>> >>experiment.
>>
>> > [snip]
>> > Run your "experiment" again but  add some pure oxygen such as was
>> > escaping from the on-board breathing oxygen tanks on the
>> > airplanes that were crashed into the WTC.
>
> No need to do it. We have the pictures of live humans waving from the
> gaping holes in the towers where the planes crashed. We have the
> testimonies of the fire fighters that the fires were not that hot and
> minor. The fuel of the plane which is mainly in the wings were severed
> outside the netting and much of them burnt outside in the fireball
> that is visible in all the videos. Futhermore, the black soot that was
> visible to the naked eye is indicative of bloody cold flame. Also, the
> probability of the oxygen tanks oriented in such a way to inject
> oxygen onto the steel as in a oxygen cutting torch is extremely low.
> These cylinders have a 1000-3000psi of pressure which makes them into
> a rocket or an explosive under uncontrolled gas release. And they
> would not contaminate the molten metal with any sulfur. Either the
> atmosphere inside was oxidising or reducing. If it was oxidising, how
> did the sulfur in huge quantities contaminate the molten metal pools?
> The official lies to explain sulfur is from the plaster wall. But that
> requires a reducing atmosphere with finely divided and intimately
> mixed reactants in a calciner where they are continuously rotated and
> run for several hours. Yet the fires ran not even for an hour before
> the building collapsed.
>

OK - given all that -- you are left with only one conclusion (or at least I 
am) -- progressive structural failure, the loss of support where the plane 
hit was sufficient to put excessive stress on the remaining structural 
members, resulting in a catastrophic sequential failure -- it doesnt take 
exotic chemical mixes to put excessive mechanical stress on a system... just 
chop out enough supports.. it may take time for the remaining supports to 
deform enough to reach the failure point.. but they will get there, as 
demonstrated -- occams razor dude -- the least hypothesis is usually the 
right one -- and I get enough conspiracy theory crap out of my dad -- makes 
a good movie -- but doesnt pan out in real life -- too many whistle-blowers 
around !!

The city I live in is installing those red-light cameras to catch 
light-runners -- my dad likes to claim that they manipulate the yellow time 
to catch people in the intersection and increase revenue from traffic 
tickets -- I told him to shut up until he got out there with a stop watch 
and proved it -- and I say the same to you -- PROVE it -- then make some 
noise -- conjecture and conspiracy theories without proof are a waste of 
everyones time. -- how do you know the sulphur was in large quantities ?? 
did you do a chemical analysis ?? or can you produce one done by a reputable 
metalurgy company ??

Ohhh and by the way -- high sulphur steels are regularly used for machined 
components -- was the amount of sulphur detected incosistent with what may 
have been present due to the use of high sulphur steels ?? (where is that 
metalurgy report again ??)



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a jet fuel/hydrocarbon fire collapse a steel structure? An experiment.

2007-02-03 Thread John Barrett

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Feb 2, 10:32 pm, "John Barrett" <[EMAIL PROTECTED]> wrote:
>> <[EMAIL PROTECTED]> wrote in message
>
>> >> > [snip]
>> >> > Run your "experiment" again but  add some pure oxygen such as was
>> >> > escaping from the on-board breathing oxygen tanks on the
>> >> > airplanes that were crashed into the WTC.
>>
>> > No need to do it. We have the pictures of live humans waving from the
>> > gaping holes in the towers where the planes crashed. We have the
>> > testimonies of the fire fighters that the fires were not that hot and
>> > minor. The fuel of the plane which is mainly in the wings were severed
>> > outside the netting and much of them burnt outside in the fireball
>> > that is visible in all the videos. Futhermore, the black soot that was
>> > visible to the naked eye is indicative of bloody cold flame. Also, the
>> > probability of the oxygen tanks oriented in such a way to inject
>> > oxygen onto the steel as in a oxygen cutting torch is extremely low.
>> > These cylinders have a 1000-3000psi of pressure which makes them into
>> > a rocket or an explosive under uncontrolled gas release. And they
>> > would not contaminate the molten metal with any sulfur. Either the
>> > atmosphere inside was oxidising or reducing. If it was oxidising, how
>> > did the sulfur in huge quantities contaminate the molten metal pools?
>> > The official lies to explain sulfur is from the plaster wall. But that
>> > requires a reducing atmosphere with finely divided and intimately
>> > mixed reactants in a calciner where they are continuously rotated and
>> > run for several hours. Yet the fires ran not even for an hour before
>> > the building collapsed.
>>
>> OK - given all that -- you are left with only one conclusion (or at least 
>> I
>> am) -- progressive structural failure, the loss of support where the 
>> plane
>> hit was sufficient to put excessive stress on the remaining structural
>> members, resulting in a catastrophic sequential failure
>
> I dont think you have seen any actual structural failures, esp
> progressive.
> That happens often in earthquake and they have stacked floors. There
> is
> famous picture of an earthquake on these websites and in the videos.
> Futhermore
> due to erratic stops and goes in the progressive failure, the
> structure falls on the side esp a big bldg like WTC1&2 should have
> fallen from the tipping torque to one side. That did not happen. only
> controlled demolition bldgs fall down straight.
>
>> -- it doesnt take
>> exotic chemical mixes to put excessive mechanical stress on a system... 
>> just
>> chop out enough supports.. it may take time for the remaining supports to
>> deform enough to reach the failure point.. but they will get there, as
>> demonstrated -- occams razor dude -- the least hypothesis is usually the
>> right one -- and I get enough conspiracy theory crap out of my dad --  
>> makes
>> a good movie -- but doesnt pan out in real life -- too many 
>> whistle-blowers
>> around !!
>
> Occams razor is applicable to nature's works. human works are not
> amenable to it. Besides, the official fairy tale is the conspiracy
> theory.
>
>> The city I live in is installing those red-light cameras to catch
>> light-runners -- my dad likes to claim that they manipulate the yellow 
>> time
>> to catch people in the intersection and increase revenue from traffic
>> tickets -- I told him to shut up until he got out there with a stop watch
>> and proved it -- and I say the same to you -- PROVE it -- then make some
>> noise -- conjecture and conspiracy theories without proof are a waste of
>> everyones time. -- how do you know the sulphur was in large quantities ??
>> did you do a chemical analysis ?? or can you produce one done by a 
>> reputable
>> metalurgy company ??
>
> These pillars are not machinable steel. the sulfur here was excessive.
> we are talking about intergranular corrosion, not that teeny amount
> used for imparting machinability and that is not nowadays needed. It
> only for cheap and rough chinese type crap and i am not sure even
> there if someone would ruin their steel mills by adding this kind of
> corrosive sulfur shit. come on dude ... dont mix categories.
>
>> Ohhh and by the way -- high sulphur steels are regularly used for 
>> machined
>> components -- was the amount of sulphur detected incosistent with what 
>> may
>&g

Re: Can a jet fuel/hydrocarbon fire collapse a steel structure? An experiment.

2007-02-03 Thread John Barrett

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Feb 2, 10:32 pm, "John Barrett" <[EMAIL PROTECTED]> wrote:
>> <[EMAIL PROTECTED]> wrote in message
>
>> >> > [snip]
>> >> > Run your "experiment" again but  add some pure oxygen such as was
>> >> > escaping from the on-board breathing oxygen tanks on the
>> >> > airplanes that were crashed into the WTC.
>>
>> > No need to do it. We have the pictures of live humans waving from the
>> > gaping holes in the towers where the planes crashed. We have the
>> > testimonies of the fire fighters that the fires were not that hot and
>> > minor. The fuel of the plane which is mainly in the wings were severed
>> > outside the netting and much of them burnt outside in the fireball
>> > that is visible in all the videos. Futhermore, the black soot that was
>> > visible to the naked eye is indicative of bloody cold flame. Also, the
>> > probability of the oxygen tanks oriented in such a way to inject
>> > oxygen onto the steel as in a oxygen cutting torch is extremely low.
>> > These cylinders have a 1000-3000psi of pressure which makes them into
>> > a rocket or an explosive under uncontrolled gas release. And they
>> > would not contaminate the molten metal with any sulfur. Either the
>> > atmosphere inside was oxidising or reducing. If it was oxidising, how
>> > did the sulfur in huge quantities contaminate the molten metal pools?
>> > The official lies to explain sulfur is from the plaster wall. But that
>> > requires a reducing atmosphere with finely divided and intimately
>> > mixed reactants in a calciner where they are continuously rotated and
>> > run for several hours. Yet the fires ran not even for an hour before
>> > the building collapsed.
>>
>> OK - given all that -- you are left with only one conclusion (or at least 
>> I
>> am) -- progressive structural failure, the loss of support where the 
>> plane
>> hit was sufficient to put excessive stress on the remaining structural
>> members, resulting in a catastrophic sequential failure
>
> I dont think you have seen any actual structural failures, esp
> progressive.
> That happens often in earthquake and they have stacked floors. There
> is
> famous picture of an earthquake on these websites and in the videos.
> Futhermore
> due to erratic stops and goes in the progressive failure, the
> structure falls on the side esp a big bldg like WTC1&2 should have
> fallen from the tipping torque to one side. That did not happen. only
> controlled demolition bldgs fall down straight.
>
>> -- it doesnt take
>> exotic chemical mixes to put excessive mechanical stress on a system... 
>> just
>> chop out enough supports.. it may take time for the remaining supports to
>> deform enough to reach the failure point.. but they will get there, as
>> demonstrated -- occams razor dude -- the least hypothesis is usually the
>> right one -- and I get enough conspiracy theory crap out of my dad --  
>> makes
>> a good movie -- but doesnt pan out in real life -- too many 
>> whistle-blowers
>> around !!
>
> Occams razor is applicable to nature's works. human works are not
> amenable to it. Besides, the official fairy tale is the conspiracy
> theory.
>
>> The city I live in is installing those red-light cameras to catch
>> light-runners -- my dad likes to claim that they manipulate the yellow 
>> time
>> to catch people in the intersection and increase revenue from traffic
>> tickets -- I told him to shut up until he got out there with a stop watch
>> and proved it -- and I say the same to you -- PROVE it -- then make some
>> noise -- conjecture and conspiracy theories without proof are a waste of
>> everyones time. -- how do you know the sulphur was in large quantities ??
>> did you do a chemical analysis ?? or can you produce one done by a 
>> reputable
>> metalurgy company ??
>
> These pillars are not machinable steel. the sulfur here was excessive.
> we are talking about intergranular corrosion, not that teeny amount
> used for imparting machinability and that is not nowadays needed. It
> only for cheap and rough chinese type crap and i am not sure even
> there if someone would ruin their steel mills by adding this kind of
> corrosive sulfur shit. come on dude ... dont mix categories.
>
>> Ohhh and by the way -- high sulphur steels are regularly used for 
>> machined
>> components -- was the amount of sulphur detected incosistent with what 
>> may
>> have been present due to the use of high sulphur steels ?? (where is that
>> metalurgy report again ??)
>
> yeah a damn fool would put sulfur in the bolts and load bearing
> elements such as the bolts of aircrafts and space shuttle.
>
> Besides how do you explain the completely pulverized building ??
> if not for explosives.
>
>

have your read THIS ??


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can a jet fuel/hydrocarbon fire collapse a steel structure? An experiment.

2007-02-03 Thread John Barrett

<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Feb 2, 10:32 pm, "John Barrett" <[EMAIL PROTECTED]> wrote:
>> <[EMAIL PROTECTED]> wrote in message
>
>> >> > [snip]
>> >> > Run your "experiment" again but  add some pure oxygen such as was
>> >> > escaping from the on-board breathing oxygen tanks on the
>> >> > airplanes that were crashed into the WTC.
>>
>> > No need to do it. We have the pictures of live humans waving from the
>> > gaping holes in the towers where the planes crashed. We have the
>> > testimonies of the fire fighters that the fires were not that hot and
>> > minor. The fuel of the plane which is mainly in the wings were severed
>> > outside the netting and much of them burnt outside in the fireball
>> > that is visible in all the videos. Futhermore, the black soot that was
>> > visible to the naked eye is indicative of bloody cold flame. Also, the
>> > probability of the oxygen tanks oriented in such a way to inject
>> > oxygen onto the steel as in a oxygen cutting torch is extremely low.
>> > These cylinders have a 1000-3000psi of pressure which makes them into
>> > a rocket or an explosive under uncontrolled gas release. And they
>> > would not contaminate the molten metal with any sulfur. Either the
>> > atmosphere inside was oxidising or reducing. If it was oxidising, how
>> > did the sulfur in huge quantities contaminate the molten metal pools?
>> > The official lies to explain sulfur is from the plaster wall. But that
>> > requires a reducing atmosphere with finely divided and intimately
>> > mixed reactants in a calciner where they are continuously rotated and
>> > run for several hours. Yet the fires ran not even for an hour before
>> > the building collapsed.
>>
>> OK - given all that -- you are left with only one conclusion (or at least 
>> I
>> am) -- progressive structural failure, the loss of support where the 
>> plane
>> hit was sufficient to put excessive stress on the remaining structural
>> members, resulting in a catastrophic sequential failure
>
> I dont think you have seen any actual structural failures, esp
> progressive.
> That happens often in earthquake and they have stacked floors. There
> is
> famous picture of an earthquake on these websites and in the videos.
> Futhermore
> due to erratic stops and goes in the progressive failure, the
> structure falls on the side esp a big bldg like WTC1&2 should have
> fallen from the tipping torque to one side. That did not happen. only
> controlled demolition bldgs fall down straight.
>
>> -- it doesnt take
>> exotic chemical mixes to put excessive mechanical stress on a system... 
>> just
>> chop out enough supports.. it may take time for the remaining supports to
>> deform enough to reach the failure point.. but they will get there, as
>> demonstrated -- occams razor dude -- the least hypothesis is usually the
>> right one -- and I get enough conspiracy theory crap out of my dad --  
>> makes
>> a good movie -- but doesnt pan out in real life -- too many 
>> whistle-blowers
>> around !!
>
> Occams razor is applicable to nature's works. human works are not
> amenable to it. Besides, the official fairy tale is the conspiracy
> theory.
>
>> The city I live in is installing those red-light cameras to catch
>> light-runners -- my dad likes to claim that they manipulate the yellow 
>> time
>> to catch people in the intersection and increase revenue from traffic
>> tickets -- I told him to shut up until he got out there with a stop watch
>> and proved it -- and I say the same to you -- PROVE it -- then make some
>> noise -- conjecture and conspiracy theories without proof are a waste of
>> everyones time. -- how do you know the sulphur was in large quantities ??
>> did you do a chemical analysis ?? or can you produce one done by a 
>> reputable
>> metalurgy company ??
>
> These pillars are not machinable steel. the sulfur here was excessive.
> we are talking about intergranular corrosion, not that teeny amount
> used for imparting machinability and that is not nowadays needed. It
> only for cheap and rough chinese type crap and i am not sure even
> there if someone would ruin their steel mills by adding this kind of
> corrosive sulfur shit. come on dude ... dont mix categories.
>
>> Ohhh and by the way -- high sulphur steels are regularly used for 
>> machined
>> components -- was the amount of sulphur detected incosistent with what 
>> may
>> ha

Odd behavior regarding a list

2009-03-26 Thread Edd Barrett
Hi there,

My first post here, so hello :)

Just a little background, I am writing my dissertation, which is a JIT
compiler based upon LLVM and it's python bindings, along with the
aperiot LL(1) parser.

I have some code here, which is not behaving as I would expect. Could
someone enlighten me as to why this is so:

---8<---
def __classdef_integer(self):
"""
class definition for a integer object.
"""

this_class = "Integer"

# metadata inherited
self.__class_data[this_class] = \
self.__class_data["Object"]

# cache parent struct sig for later (when casting ptrs)
parent_struct_sig = \
self.__class_data[this_class]["struct-sig"]

this_cdata = self.__class_data[this_class]
#this_cdata["membernames"].append("value")
#this_cdata["type-sym"] = 1
#this_cdata["parent-class"] = "Object"

#vtab = self.__construct_vtable(this_class)
#self.__ir_add_typesym(this_class, vtab)


print "parent"
print parent_struct_sig
this_cdata["struct-sig"].append(self.__int_t)
print "new"
print parent_struct_sig

sys.exit(1)
 ---8<---

Notice how I am caching the old value of 'parent_struct_sig' before I
manipulate it.

Produces the following output:

---8<---
parent
[]
new
[, ]
---8<---

My question is: why has 'parent_struct_sig' changed? I was under the
impression the assignment operator copies, not references.

Sorry if the answer is blindingly obvious. I am somewhat jaded from
working on this every day :P

Heres my python environment:
---8<---
Python 2.6.1 (r261:67515, Dec 27 2008, 16:56:14)
[GCC 4.2.0 20070307 (prerelease)] on openbsd4
Type "help", "copyright", "credits" or "license" for more information.
---8<---

Thanks
--
http://mail.python.org/mailman/listinfo/python-list


Re: Odd behavior regarding a list

2009-03-26 Thread Edd Barrett
Hi there,

First of all, thanks to everyone for replying. This has been a great
help.

On Mar 26, 4:21 pm, Steven D'Aprano  wrote:
> On Thu, 26 Mar 2009 08:36:49 -0700, Edd Barrett wrote:
> > My question is: why has 'parent_struct_sig' changed? I was under the
> > impression the assignment operator copies, not references.
>
> You are mistaken. Firstly, Python does not have an assignment operator.
> Assignment (technically, name binding) is not an operator in Python. You
> can't over-ride it.
>
> Secondly, assignment in Python *never* copies. Ever. The only time a copy
> is made is when you explicitly ask for a copy.

This explains it.

>
> e.g. to copy a list L, use one of:
>
> list(L)
>
> L[:]

Great :)


> A few more comments, based on your code.
>
> >    def __classdef_integer(self):
>
> Double-underscore name mangling is often more trouble than it is worth.
> Unless you really need it, not just think you will need it, it is
> generally considered poor style.

It was an attempt at encapsulation. I didn't want my parser to call
internals willy-nilly.  Is there a better way?

>
> ...
>
> >            # cache parent struct sig for later (when casting ptrs)
>
> If you're actually casting pointers in your code, I don't know what
> language you're using, but it isn't Python! Python is not C, you don't
> have direct access to pointers. I don't know what you're doing, perhaps
> the comment is misleading?

This is not reffering to anything python :P
I will be casting some pointer types in LLVM assembler. Python is
going to generate this code.

>
> ...
>
> >            sys.exit(1)
>
> You do realise that this line tells your program to exit? Seems like a
> strange thing to include in a method.

I'm just debugging this part of code. Obviously this is removed now.

> Hope some of this is helpful.

Very! Many thanks.


--

Edd

--
http://mail.python.org/mailman/listinfo/python-list


collections.namedtuple: conflicting instances?

2010-09-23 Thread David A. Barrett
 I've noticed that it's possible to create conflicting instances of the 
collections.namedtuple class:


  from collections  import namedtuple as nt
  IX = nt('X', 'a b')
  IY = nt('Y', 'c d')
  x = IX(0, 1)
  y = IY(2, 3)

The above are non-conflicting class instances and of two distinct 
namedtuple classes and distinct instances of those classes, but what 
happens with this?


  IX2 = nt('X', 'g')
  z = IX2(10)

It looks like IX and IX2 are two distinct classes, which makes sense, 
but what is the classname parameter passed to the constructor used for?  
Is it an error to construct two distinct classes with the same value?


I was wondering if it's useful to allow duplicate (consistant) 
constructions, but have them simply return the same class instance.  
Should inconsistant constructions with the same name raise and exception?

--
http://mail.python.org/mailman/listinfo/python-list