Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
QuarkJets
Sep 8, 2008

ARACHNOTRON posted:

It would be nice if it searched back until it didn't find an init file. I don't know.

I have only done Java packaging and it kinda just works, especially with JARs :(

Ah, but Python also supports importing files that reside in directories without an init file. And you might have more than one area holding .py files that you want to use, which would ultimately necessitate some sort of PATH variable anyway

(Java uses a PATH-like variable, too, it was probably set for you by your IDE if you're working in Windows. I think it's JAVAHOME? I haven't used Java in a long time)

Adbot
ADBOT LOVES YOU

Dren
Jan 5, 2001

Pillbug

ARACHNOTRON posted:

Why does packaging in Python have to be so weird :(

I am following instructions but stuff doesn't work. My package structure is:
code:
package/
| __init__.py
|
| subpackage1/
| | __init__.py
| | {files}
|
| subpackage2/
| | __init__.py
| | {files}
But for a file in subpackage1,
Python code:
import package.subpackage2.x
- ImportError: No module named package.subpackage2.x

from package.subpackage2 import x
- ImportError: No module named package.subpackage2

import subpackage2.x
- ImportError: No module named subpackage2.x

from subpackage2 import x
- ImportError: No module named subpackage2
how do I even do this


edit:
I used PyDev for Eclipse to convert the main package folder to a source folder because it wasn't for some reason and it works?? Doesn't make sense to me though.

edit again:
It only works in Eclipse :(

You are thinking in .NET (or java w/ eclipse). In .NET and in eclipse you can put your files any god drat place you please and the IDE will manage the visibility of the packages for you. The most you'll ever have to do is mess with the dependency checkboxes if you've set up multiple projects.

In python your import visibility is defined by sys.path, as others have mentioned. Your import include path also has the working directory of the current module in it. This means that for the directory structure you've specified a file in subpackage1 cannot import package.subpackage2 or subpackage2 unless sys.path is modified (which you shouldn't do). If subpackage1 requires subpackage2 then subpackage2 should be a sub package of subpackage1. i.e.
code:
package/
 | __init__.py
 | turds.py
 |
 | subpackage1/
 | | __init__.py
 | | poop.py
 | | 
 | | subpackage2/
 | | | __init__.py
 | | | dongs.py
Assuming you provide visibility to poop and dongs by importing them in their __init__.py files the following imports will work.

turds.py can do:
code:
import subpackage1
from subpackage1 import poop
from subpackage1 import subpackage2
from subpackage1 import subpackage2.dongs
poop.py can do:
code:
import subpackage2
from subpackage2 import dongs
dongs.py can only import stuff in subpackage2.

I believe in this way of thinking, as I have recently dealt with a compiling a C project in linux that someone had written in Visual Studio. Their directory structure was out of whack with their dependency structure in exactly the way you are describing. They had a subpackage2 at the same directory level as subpackage1, but subpackage1 depended on subpackage2 and the linux make system had no visibility to the files it needed. IDEs that build for you make awful directory layouts easy.

Dren fucked around with this message at 08:30 on Mar 31, 2013

Dominoes
Sep 20, 2007

What's the most current form of Oauth for Python 3? I'm trying to create a stock screener using my broker's API, which uses Oauth. Most of the info I find is out of date or conflicting. I've seen the following modules referenced:

Oauth - seems to be the original, now outdated. I get an error of "'module' object has no attribute 'Consumer'"
Oauth2 - Newer version, apparently also outdated? The one most referenced one online. Glitches out in pip/can't figure out how to install it.
Oauthlib - IIRC, claims to be the new replacement for Oauth and Oauth2
Rauth.OAuth2Service - Also potentially replacement for Oauth and Oauth2?
Requests - ?
Oauth_hook - ?
pyoauth2 - I get an error about not having a module named "client" in pyoauth2's init.

Which should I use?

Dominoes fucked around with this message at 18:39 on Mar 31, 2013

My Rhythmic Crotch
Jan 13, 2011

Anyone ever found a database backend for Flask that supports generic foreign keys? I see there is some experimental support for it in Peewee, but it's not quite what I would really call fully generic. From what I can tell about SqlAlchemy, it doesn't really do generic foreign keys either.

Lurchington
Jan 2, 2003

Forums Dragoon

Dominoes posted:

What's the most current form of Oauth for Python 3? I'm trying to create a stock screener using my broker's API, which uses Oauth. Most of the info I find is out of date or conflicting. I've seen the following modules referenced:

Oauth - seems to be the original, now outdated. I get an error of "'module' object has no attribute 'Consumer'"
Oauth2 - Newer version, apparently also outdated? The one most referenced one online. Glitches out in pip/can't figure out how to install it.
Oauthlib - IIRC, claims to be the new replacement for Oauth and Oauth2
Rauth.OAuth2Service - Also potentially replacement for Oauth and Oauth2?
Requests - ?
Oauth_hook - ?
pyoauth2 - I get an error about not having a module named "client" in pyoauth2's init.

Which should I use?

I've used tweepy before: http://tweepy.github.com/
which uses OAuth to against twitter, but their setup.py doesn't really make it clear which it uses. It was solid overall. edit: although I guess I wouldn't have used it in 3.x, sorry :-/

Lurchington fucked around with this message at 22:53 on Mar 31, 2013

Haystack
Jan 23, 2005





My Rhythmic Crotch posted:

Anyone ever found a database backend for Flask that supports generic foreign keys? I see there is some experimental support for it in Peewee, but it's not quite what I would really call fully generic. From what I can tell about SqlAlchemy, it doesn't really do generic foreign keys either.

As far as SQLAlchemy goes, would the generic association examples talked about here and found here do the trick?

Smarmy Coworker
May 10, 2008

by XyloJW

Dren posted:

You are thinking in .NET (or java w/ eclipse). In .NET and in eclipse you can put your files any god drat place you please and the IDE will manage the visibility of the packages for you. The most you'll ever have to do is mess with the dependency checkboxes if you've set up multiple projects.

In python your import visibility is defined by sys.path, as others have mentioned. Your import include path also has the working directory of the current module in it. This means that for the directory structure you've specified a file in subpackage1 cannot import package.subpackage2 or subpackage2 unless sys.path is modified (which you shouldn't do). If subpackage1 requires subpackage2 then subpackage2 should be a sub package of subpackage1. i.e.
code:
package/
 | __init__.py
 | turds.py
 |
 | subpackage1/
 | | __init__.py
 | | poop.py
 | | 
 | | subpackage2/
 | | | __init__.py
 | | | dongs.py
Assuming you provide visibility to poop and dongs by importing them in their __init__.py files the following imports will work.

turds.py can do:
code:
import subpackage1
from subpackage1 import poop
from subpackage1 import subpackage2
from subpackage1 import subpackage2.dongs
poop.py can do:
code:
import subpackage2
from subpackage2 import dongs
dongs.py can only import stuff in subpackage2.

I believe in this way of thinking, as I have recently dealt with a compiling a C project in linux that someone had written in Visual Studio. Their directory structure was out of whack with their dependency structure in exactly the way you are describing. They had a subpackage2 at the same directory level as subpackage1, but subpackage1 depended on subpackage2 and the linux make system had no visibility to the files it needed. IDEs that build for you make awful directory layouts easy.

Pretty reasonable and understandable. I just wanted to group things up for now and have things look nice (even though I was going to split it all up across multiple servers later) because I'm dumb.


QuarkJets posted:

Ah, but Python also supports importing files that reside in directories without an init file. And you might have more than one area holding .py files that you want to use, which would ultimately necessitate some sort of PATH variable anyway

(Java uses a PATH-like variable, too, it was probably set for you by your IDE if you're working in Windows. I think it's JAVAHOME? I haven't used Java in a long time)

Java's classpath is defined locally for every project at compile (basically just set to the current folder) which I guess doesn't help me at all when I work in other languages :(

My Rhythmic Crotch
Jan 13, 2011

Haystack posted:

As far as SQLAlchemy goes, would the generic association examples talked about here and found here do the trick?
Well, I'm not quite sure that's what I am after.

Purely as an exercise, I wanted to see how easy or difficult it would be to implement foreign keys which could point to an instance of any child class of a particular parent class. Turns out I guess you need generic foreign keys for that.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Is anyone aware of a library or snippet for parsing ranges? Specifically, I'm looking for the ability to take string input like "1-7, 13, 24, 100-192", "K-W", or whatever else kind of weird range thing you can think of and be able to get a list or something sane out of that input.

I just don't feel like writing it right now...

Emacs Headroom
Aug 2, 2003
Here's an untested braindead solution:

Python code:
s = "1-7, 13, 24, 100-192"
all_ranges = []
for e in s.split(', '):
    v = e.split('-')
    if len(v) == 1:
        all_ranges.append(int(v))
    elif len(v) == 2:
        all_ranges = all_ranges + range(int(v[0]), int(v[1])+1)
    else:
        raise SomeError
return all_ranges

Malcolm XML
Aug 8, 2009

I always knew it would end like this.
Flask owns, why I have I been banging my head against the django wall for so long.

Anyone know a good django admin replacement?

The Gripper
Sep 14, 2004
i am winner

Malcolm XML posted:

Flask owns, why I have I been banging my head against the django wall for so long.

Anyone know a good django admin replacement?
I've used flask-admin with success, and it looks to be the most lightweight of all the options available, plus its well documented.

Social Animal
Nov 1, 2005

So I learned the basics of Python from code academy and now I really want to start a small project to practice. I was thinking of a page I can upload/download files from sort of like my own ghetto megaupload. What's a good place to start? I looked at Flask and it looks like I can use this but I'm hitting a brick wall. When it comes to coding I am pretty bad (probably why I was attracted to Python's easy to use/read syntax.) The problem is it feels like frameworks are a whole different language in themselves, and I'm pretty lost. Can anyone please recommend me a good tutorial or path I should take to really start learning? Or recommend a good beginner's project I can start with?

I really want to get into coding but I get overwhelmed easily.

QuarkJets
Sep 8, 2008

Social Animal posted:

So I learned the basics of Python from code academy and now I really want to start a small project to practice. I was thinking of a page I can upload/download files from sort of like my own ghetto megaupload. What's a good place to start? I looked at Flask and it looks like I can use this but I'm hitting a brick wall. When it comes to coding I am pretty bad (probably why I was attracted to Python's easy to use/read syntax.) The problem is it feels like frameworks are a whole different language in themselves, and I'm pretty lost. Can anyone please recommend me a good tutorial or path I should take to really start learning? Or recommend a good beginner's project I can start with?

I really want to get into coding but I get overwhelmed easily.

Have you completed the Python Challenge yet? That's a really good first project

Social Animal
Nov 1, 2005

This is the only page I could find:

http://www.pythonchallenge.com/

Is this the one? If so love that page design.

QuarkJets
Sep 8, 2008

Social Animal posted:

This is the only page I could find:

http://www.pythonchallenge.com/

Is this the one? If so love that page design.

That's the one. It was made in 2005, so not exactly the height of web design

My Rhythmic Crotch
Jan 13, 2011

Social Animal posted:

So I learned the basics of Python from code academy and now I really want to start a small project to practice. I was thinking of a page I can upload/download files from sort of like my own ghetto megaupload. What's a good place to start? I looked at Flask and it looks like I can use this but I'm hitting a brick wall. When it comes to coding I am pretty bad (probably why I was attracted to Python's easy to use/read syntax.) The problem is it feels like frameworks are a whole different language in themselves, and I'm pretty lost. Can anyone please recommend me a good tutorial or path I should take to really start learning? Or recommend a good beginner's project I can start with?

I really want to get into coding but I get overwhelmed easily.
If I remember correctly, Flask comes with an example project that is a very simple twitter clone. Have you looked at it? You could start there, examining what each part does, and begin modifying it so that users can upload files.

Dominoes
Sep 20, 2007

I'm new to programming (Finished Codeacademy labs recently), and am running into long data-crunching times on a stock screener I'm working on. The functions below parse a .CSV file and compare its values to input numbers. Doing this for a maximum* of 20,000 cells takes 1 minute. *The actual number should be smaller, since a failed cell should skip the rest of its row. (The break in the second function below)

Is the time due to sloppy code? Is it normal? Is it a limit of python, compared to C++? Python's using 35% of my CPU while the evaluation's occurring.

The 'evaluate' function is a method of a class whose instances are contained in 'parameters' input for the 'passing_stocks' function. I removed some dubugging, output and formatting code.
code:
def evaluate(self, x, y):
#Determines if a data.csv cell is between the Parameters instance's floor and ceiling
    cell_value = read_cell(x, y, 'data.csv')
    if self._floor <= float(cell_value) <= self._ceil:
        return True
    else:
        return False
code:
def passing_stocks(stocks, parameters):
#Runs the evaluate function for the input stock and parameter lists
    result = []
    y = 0
    for n2 in stocks:
        failed = False
        for n in parameters:
            if n.evaluate(n.csv_col, y) == False:
                failed = True
                break
        if failed == False:
            result.append(n2)
        y += 1
    return result

Dominoes fucked around with this message at 16:32 on Apr 3, 2013

a lovely poster
Aug 5, 2011

by Pipski
Is there any way you can the data you're pulling to do some of the heavy lifting for yourself? What kind of screens do you want to use? How many stocks are you pulling information for?

Python is not really great for real-time financial stuff because of it's slower speed. Honestly anything dealing with real-time market data is not a good project for a beginner programmer. Good luck!

Dominoes
Sep 20, 2007

a lovely poster posted:

Is there any way you can the data you're pulling to do some of the heavy lifting for yourself? What kind of screens do you want to use? How many stocks are you pulling information for?

Python is not really great for real-time financial stuff because of it's slower speed. Honestly anything dealing with real-time market data is not a good project for a beginner programmer. Good luck!

I want to screen for price, % change, average volume, and possibly some other real-time criteria. I also want to screen for price changes over selectable increments of time - a function I haven't found on any existing screener.

I'm using Yahoo Finance. For now, I'm using a canned list of stocks pulled from the nyse, nasdaq and s&p500 website - about 5,000 total. I'm pulling the real-time data into a .csv, in 200-stock-per-query increments, the max allowed by Yahoo. Surprisingly, this takes substantially less time than the actual number crunching.

I'm also pulling and analyzing historical price data, which the functions I posted don't deal with. I'll post them, or the whole program if you're curious. Unfortunately, I can only seem to pull the historical data one-stock-at a time, so I've been pulling and analyzing a stock, then looping, instead of pre-downloading. I'm only pulling/analyzing historical data for stocks that passed the real-time screening.

I'm trying to set up the program to work with my broker (tradeking) as well, but I'm having trouble getting Oauth to work with Python 3 - that's what my previous post in this thread was about.

Dominoes fucked around with this message at 16:47 on Apr 3, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
It's likely the reason it's slow is because it's reading the data file from the disk for every cell. If these are not sequential reads, then the disk is going to be bouncing around all over the place.

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.

Dominoes posted:

Is the time due to sloppy code?

What does the function read_cell look like?

Dominoes
Sep 20, 2007

DARPA posted:

What does the function read_cell look like?
Here's the read_cell function:
code:
from csv import reader

def read_cell(x, y, file_name):
#Returns a cell value in a csv
    with open(file_name, 'r') as f:
        myreader = reader(f)
        y_count = 0
        for n in myreader:
            if y_count == y:
                cell = n[x]
                return cell
            y_count += 1
Perhaps there's a way to go directly to the row I want without looping through each one?

Dominoes fucked around with this message at 16:57 on Apr 3, 2013

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.
[I think] read_cell is your issue. For each cell you check in evaluate() you are reopening the csv file and iterating through the lines. You are triple nesting loops for something like Number_Of_Stocks * Number_Of_Parameters * Lines_In_File.

If you have the memory for it, open the file once, read it into a list, something like (assuming you're using csv.reader):
Python code:
import csv
lines = []
for row in csv.reader(open('data.csv')):
    lines.append(row)

# Or a list comprehension if you want to be fancy
lines = [row for row in csv.reader(open('data.csv'))]
then you can directly address the cell you want with lines[x][y].

edit: evilentity suggests below using list() which definitely clearer than a loop or comprehension.

DARPA fucked around with this message at 18:08 on Apr 3, 2013

evilentity
Jun 25, 2010

Dominoes posted:

Here's the read_cell function:
Python code:
def read_cell(x, y, file_name):
#Returns a cell value in a csv
    with open(file_name, 'r') as f:
        myreader = reader(f)
        y_count = 0
        for n in myreader:
            if y_count == y:
                cell = n[x]
                return cell
            y_count += 1

And thats the reason why its so slow. Read the whole file into memory and go from there. I assume reader is csv.reader. Something like that should do:
Python code:
def load_csv(file_name):
    with open(file_name, 'r') as f:
        return list(reader(f))
csv_data = load_csv(...)

print dsv_data[x][y]
Edit: beaten into the ground.

Dren
Jan 5, 2001

Pillbug
Dominos, lets pump the brakes a little bit.

The way you're accessing your data is very crude. Each time you need to access a cell you're opening the file, seeking to the row containing that record, parsing the row data, then returning the cell. Compared to memory access, disk access is very slow. To speed this operation up you should load all of your data into one of python's wonderful data structures and access it there. It doesn't sound like data.csv is very big so this won't be a problem. If your source data is too large to easily fit into memory you'll need to store it in a database and access it from there.

Here's some sample code to get you started:
Python code:
from csv import reader

def loadDataFile(file_name):
    data = []
    with open(file_name, 'r') as f:
        myreader = reader(f)
        for row in myreader:
            data.append(row)
    return data

data = loadDataFile('data.csv')

# to get a cell do
print data[5][6]

Dominoes
Sep 20, 2007

Thanks guys - Really appreciate it. Going to fix it this evening!

Pivotal Lever
Sep 9, 2003

Dominoes posted:

Thanks guys - Really appreciate it. Going to fix it this evening!

Another tip, if there's a module for what you're trying to do in the standard library, use it instead of rolling your own solution.

JetsGuy
Sep 17, 2003

science + hockey
=
LASER SKATES

Thermopyle posted:

Is anyone aware of a library or snippet for parsing ranges? Specifically, I'm looking for the ability to take string input like "1-7, 13, 24, 100-192", "K-W", or whatever else kind of weird range thing you can think of and be able to get a list or something sane out of that input.

I just don't feel like writing it right now...

Have you tried numpy.fromstring?
http://docs.scipy.org/doc/numpy/reference/generated/numpy.fromstring.html#numpy.fromstring

I'm not certain it would handle multiple delimiters very well. My first impression with your problem is I'd just run a str.split() on it and than iterate over it to substitute range() for any instance where it saw "-". Of course, that doesn't address your question of a simple function to just do it.

That kind of thing seems common enough that I'd be mildly surprised if NumPy didn't have a function to at least handle it halfway for you. Here's the list of all their array creation methods.

http://docs.scipy.org/doc/numpy/reference/routines.array-creation.html

Dren
Jan 5, 2001

Pillbug

Pivotal Lever posted:

Another tip, if there's a module for what you're trying to do in the standard library, use it instead of rolling your own solution.

But he don't know what he don't know!

Dominoes
Sep 20, 2007

Problem solved! I used evilentity's load_csv function. I added this line at the top of passing_stocks: "data = load_csv('data.csv')" Read cell now looks like this:

code:
def read_cell(x, y, data):
#Returns a cell value in a compound list
        y_count = 0
        for n in data:
            if y_count == y:
                cell = n[x]
                return cell
            y_count += 1
I added a third parameter to evaulate called data, and added it to the call in passing_stocks, which now reads "if n2.evaluate(n2.csv_col, y, data) == False:"

Pivotal Lever posted:

Another tip, if there's a module for what you're trying to do in the standard library, use it instead of rolling your own solution.
Are you referring to the list() function, or is there something else I can replace?

accipter
Sep 12, 2003

Dominoes posted:

(slow code)

Just to point out that you can better understand how much time is time spent on each portion of your code by profiling it. Python makes this pretty simple:

code:
python -m cProfile myscript.py

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Dominoes posted:

code:
def read_cell(x, y, data):
#Returns a cell value in a compound list
        y_count = 0
        for n in data:
            if y_count == y:
                cell = n[x]
                return cell
            y_count += 1

This is literally equivalent to data[x][y].

DARPA
Apr 24, 2005
We know what happens to people who stay in the middle of the road. They get run over.

Dominoes posted:

Problem solved! I used evilentity's load_csv function. I added this line at the top of passing_stocks: "data = load_csv('data.csv')" Read cell now looks like this:

code:
def read_cell(x, y, data):
#Returns a cell value in a compound list
        y_count = 0
        for n in data:
            if y_count == y:
                cell = n[x]
                return cell
            y_count += 1
I added a third parameter to evaulate called data, and added it to the call in passing_stocks, which now reads "if n2.evaluate(n2.csv_col, y, data) == False:"

Are you referring to the list() function, or is there something else I can replace?

You are still walking the full length of the lists. You can directly address the cell.

You can write :
Python code:
cell = data[y][x]
and get rid of your for loop. You don't even need to call read_cell() at all now. You can just access the cell directly inside evaluate() using data[y][x].

Dominoes
Sep 20, 2007

DARPA posted:

You are still walking the full length of the lists. You can directly address the cell.

You can write :
Python code:
cell = data[y][x]
and get rid of your for loop. You don't even need to call read_cell() at all now. You can just access the cell directly inside evaluate() using data[y][x].
Nice; that worked. Removing the repeated disk reads reduced the time from a minute to a second. Getting rid of the line-by-line read loop made the load instantaneous.

Dominoes fucked around with this message at 22:23 on Apr 3, 2013

FoiledAgain
May 6, 2007

What could I have done to cause this behaviour? (Here x and y are instances of a class I created, so maybe I screwed something up there?)

code:
>>>x==y
True
>>>x in mydict.keys()
True
>>>y in mydict.keys()
True
>>>mydict[x]
1
>>>mydict[y]
KeyError: y

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
__eq__ evaluating to be the same but __hash__ evaluating to different hashes.

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug
You can do this with a mismatch between __eq__ and __hash__, like so:

Python code:
class Test:
    def __init__(self, v1, v2):
        self.v1 = v1
        self.v2 = v2
    def __eq__(self, other):
        return self.v1 == other.v1
    def __hash__(self):
        return self.v1 * 9 + self.v2

x = Test(1, 2)
y = Test(1, 3)
print('x == y -> {}'.format(x == y))

d = {x: 'x'}

print('x in d.keys() -> {}'.format(x in d.keys()))
print('y in d.keys() -> {}'.format(y in d.keys()))
print('x in d -> {}'.format(x in d))
print('y in d -> {}'.format(y in d))
print('d[x] -> {}'.format(d[x]))
print('d[y] -> {}'.format(d[y]))
code:
$ python test.py
x == y -> True
x in d.keys() -> True
y in d.keys() -> False
x in d -> True
y in d -> False
d[x] -> x
Traceback (most recent call last):
  File "test.py", line 21, in <module>
    print('d[y] -> {}'.format(d[y]))
KeyError: <__main__.Test object at 0x7f6e201d5350>
In old versions of Python, however, dict.keys() returns a list, and checking for membership in a list uses equality comparisons rather than the hash of an object. Note the difference below:
code:
$ python2 test.py 
x == y -> True
x in d.keys() -> True
y in d.keys() -> True
x in d -> True
y in d -> False
d[x] -> x
Traceback (most recent call last):
  File "test.py", line 21, in <module>
    print('d[y] -> {}'.format(d[y]))
KeyError: <__main__.Test instance at 0xed1488>
Corollary: don't use x in mydict.keys(). The semantics aren't quite the same as what you surely intended to do: x in mydict.

The contract of Java's Object#hashCode is worth reading; it applies to Python also.

FoiledAgain
May 6, 2007

I had set my own __eq__ and __ne__, but I didn't know there was a __hash__, so that really helps a lot. And thanks for the very nice demonstration of how this work, Lysidas!

Adbot
ADBOT LOVES YOU

Bigup DJ
Nov 8, 2012
So I'm learning Python and I was fiddling with list comprehensions:

Python code:
c = [x**2**(y-1)**2 for x in range(11) for y in range(11)]
When I tried that all I got was empty white lines until I restarted the shell. Even after I undid it with ctrl+z, none of my input returned anything but white lines. What's happening?

  • Locked thread