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.
 
  • Post
  • Reply
Thermopyle
Jul 1, 2003

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

vikingstrike posted:

I’m a conda user too that would be up for trying something new that’s supported more generally by the language. Couple of questions:

- To install packages, would I just use pip once the environment is activated?
- What would be the easiest way to install MKL compiled packages like numpy? The ease of this is one the things that attracted me to conda

Not really related, but has anyone used the Intel python distribution? How does it differ from the packages I install through conda? I’ve seen reports online of where it’s quicker but I feel like I’m missing something.

To install packages, you just type pipenv install numpy while you are in your projects directory.

It will download the wheel and install it in the correct virtualenv for your project.

I just tried numpy on my Windows machine (traditionally where you have the most problems with compiled packages):

code:
> pipenv install numpy
Installing numpy…
Looking in indexes: [url]https://pypi.python.org/simple[/url]
Collecting numpy
  Downloading [url]https://files.pythonhosted.org/packages/c6/dd/9dce3596b9ed768cc7e3037d8d1729a87fb963317e2e280d4f95d39f3f81/numpy-1.14.3-cp36-none-win32.whl[/url] (9.8MB)
Installing collected packages: numpy
Successfully installed numpy-1.14.3

Adding numpy to Pipfile's [packages]…
Pipfile.lock (b8f454) out of date, updating to (259a79)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (259a79)!
Installing dependencies from Pipfile.lock (259a79)…
  ================================ 18/18 - 00:00:05
To activate this project's virtualenv, run the following:
 $ pipenv shell
Though, its success is not really due to anything pipenv is doing. The compiled packages problem is getting to be less and less of a problem as more and more packages are distributing wheels.

Adbot
ADBOT LOVES YOU

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
He asked specifically about MKL linked numpy though. In my experience MKL >>> every other implementation so its kinda important/worth it. conda makes it super easy without having to mess around with $LD_LIBRARY_PATH etc.

e: Not saying pipenv is universally bad or that conda is universally better or anything. Just that there is a use case for conda that pipenv doesn’t seem to solve.

e2: To use the intel python distribution you just do

code:
conda create -n myenv -c intel python=3.6 numpy ...
I’m not sure if there’s any benefit to using that specific python interpreter though, vs just grabbing “mkl numpy” from the default channel.

Boris Galerkin fucked around with this message at 19:13 on May 15, 2018

Thermopyle
Jul 1, 2003

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

Oh, I skimmed right over the MKL part.

Thermopyle
Jul 1, 2003

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

Though, if you wanted to use pipenv for some reason, you can of course download the numpy-mkl wheel and install it by pipenv install numpy-mkl.whl.

To be clear, I'm very torn between several of these attempted solutions. For example, I do not like that pipenv defaults to wildcard versions on installed packages. It should pin the version number by default.

In fact, poetry seems to do a lot better with regards to a lot of this stuff. Unfortunately, I like the transparent virtualenv handling that pipenv does so I'm constantly torn between the two.

edit: oh another thing that poetry does better than pipenv...you don't have to manage a Pipfile (or requirements.txt) in addition to a setup.py file.

edit2: Like I said on that reddit thread, I think its better that a good-enough tool becomes a standard in the python community soon rather than a perfect tool at some later time.

Thermopyle fucked around with this message at 19:37 on May 15, 2018

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Apparently you can also do this

code:
$ pipenv --python /path/to/condaenv/python --site-packages
$ pipenv install
From pipenv with some packages from conda.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies

Thermopyle posted:

Though, if you wanted to use pipenv for some reason, you can of course download the numpy-mkl wheel and install it by pipenv install numpy-mkl.whl.

To be clear, I'm very torn between several of these attempted solutions. For example, I do not like that pipenv defaults to wildcard versions on installed packages. It should pin the version number by default.

In fact, poetry seems to do a lot better with regards to a lot of this stuff. Unfortunately, I like the transparent virtualenv handling that pipenv does so I'm constantly torn between the two.

edit: oh another thing that poetry does better than pipenv...you don't have to manage a Pipfile (or requirements.txt) in addition to a setup.py file.

edit2: Like I said on that reddit thread, I think its better that a good-enough tool becomes a standard in the python community soon rather than a perfect tool at some later time.
Yeah, and poetry is completely unusable for Homebrew Python installations so good luck getting that to catch on till that's fixed.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I am looking into using asyncio coroutinea and I believe the normal event loop is designed to block the thread until all coroutines finish. In particular, I am fixed on run_until_complete. Is this true? If so, has anybody seen an alternate scheduler that is meant to be manually ticked instead?

Thermopyle
Jul 1, 2003

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

Is there a reason you don't want to run the event loop in its own thread?

Sad Panda
Sep 22, 2004

I'm a Sad Panda.
I'm struggling to work out the best way to structure my project. It'll be written in Python, but feel free to point me to a different thread if I should be using that instead.

There is a database of about 200 websites. The code will..
1. Check the database and get the list of sites that it is supposed to be checking based on a value.
2. Access each of those websites and perform 2 functions, load() and scrape() for some Selenium-based magic to scrape some data.
3. Write that data back to the database.

Conceptually the simplest is the bruteforce option of ignoring the database and writing 200 very similar python files and then manually running them all. However, that sounds like a very tedious idea, and not at all scalable in the way this should be.

The next level of involves a ridiculous if elif elif elif elif else statement saying "if the site is x then run this script elif ..." all the way through the 200 sites. Also, a bad idea.

The best idea (probably bad) idea that I've got is to write the load() function, store it in the database, call it and then exec(load_script), but I assume that's bad too.

vikingstrike
Sep 23, 2007

whats happening, captain
How similar are the sites you need to scrape? How often do they change format?

Lpzie
Nov 20, 2006

Curious if anyone has an idea how to approach something I want to code.

I have data that look like this:



Ultimately, I want to give the user the ability to select a region on the map and calculate the RMS. For now, I need to figure out how to draw the circle (or rect) and retain the coordinates. I've been looking at the matplotlib event handling stuff but I'm not quite following it.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

vikingstrike posted:

How similar are the sites you need to scrape? How often do they change format?

Very. I'll be logging in to each site and there's not going to be much standardisation.

There are updates every now and then but infrequently enough that once I get it all done at first I don't mind tweaking it when they change.

vikingstrike
Sep 23, 2007

whats happening, captain

Sad Panda posted:

Very. I'll be logging in to each site and there's not going to be much standardisation.

There are updates every now and then but infrequently enough that once I get it all done at first I don't mind tweaking it when they change.

If they are all different, the scraping problem is going to be hard to generalize. Hopefully you can generalize it to a few cases and go from there. Although, not knowing more about what you're trying to scrape and how it is presented, this may not be as annoying as it appears at first read.

Thermopyle and Boris Galerkin, thanks for the responses. I'm probably going to stick with conda for the time being since it suits my needs quite well. I don't do anything to complex, so just having two environments for 2.7 and 3.6 along with my standard data science/data analysis libraries does it for me. Now that pycharm allows for separate conda environments per project, I may play around with that, but I never have to package code to distribute it, so I don't think I'm doing anything super terrible. I know that pandas, for example, can change code and it will alter the output at times of functions, which would be handled by a single environment per project, but this isn't common and is usually really easy to spot. Maybe for my next round of work, I'll change things up.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies

Sad Panda posted:

Very. I'll be logging in to each site and there's not going to be much standardisation.

There are updates every now and then but infrequently enough that once I get it all done at first I don't mind tweaking it when they change.
As vikingstrike said, if it's possible to generalize, you should try and do that. But if each site is unique enough that they require their own parser, your best bet is to store the scraping code in a DB or dynamically load it from a directory (I'd chose the latter as it'll be way easier to update and version control). But even in those cases, see if there isn't generalized helper functions you can write for it.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Thermopyle posted:

Is there a reason you don't want to run the event loop in its own thread?

Most every line of code will interact with data in the original thread. It is not performance-intensive; I just want to be able to write them out without throwing around a bunch of context objects.

SurgicalOntologist
Jun 17, 2004

Lpzie posted:

Curious if anyone has an idea how to approach something I want to code.

I have data that look like this:



Ultimately, I want to give the user the ability to select a region on the map and calculate the RMS. For now, I need to figure out how to draw the circle (or rect) and retain the coordinates. I've been looking at the matplotlib event handling stuff but I'm not quite following it.

Check out holoviews and/or Bokeh.

http://holoviews.org/reference/apps/bokeh/selection_stream.html#bokeh-gallery-selection-stream
https://demo.bokehplots.com/apps/selection_histogram

Thermopyle
Jul 1, 2003

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

Rocko Bonaparte posted:

Most every line of code will interact with data in the original thread. It is not performance-intensive; I just want to be able to write them out without throwing around a bunch of context objects.

I'm having a hard time imagining your question even making conceptual sense, but that's probably just me being slow. Like, how do you imagine an event loop not running in another thread while at the same time not blocking the current thread?


FWIW, there's a list of some alternative event loops here.

Cingulate
Oct 23, 2012

by Fluffdaddy
I'm setting up a static website, hopefully so it's community editable. So I'm thinking markdown and GitHub. I only really know Python, so I went for Pelican, but now I'm wondering if I shouldn't just suck it up and use Jekyll. Thoughts from the more experienced people ITT?

Thermopyle
Jul 1, 2003

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

Are you sure you want something like that instead of a wiki? A wiki is the first thing I thought of when you said "community editable".

Cingulate
Oct 23, 2012

by Fluffdaddy

Thermopyle posted:

Are you sure you want something like that instead of a wiki? A wiki is the first thing I thought of when you said "community editable".
For various reasons, no. It's in part representation.

Also I want to force feed GitHub and markdown down their throats anyways :colbert:

mr_package
Jun 13, 2000
Has everyone ditched os.path in favor of pathlib? For new code/projects would you treat os.path as deprecated or would you just use whatever is easier for you?

Dominoes
Sep 20, 2007

mr_package posted:

Has everyone ditched os.path in favor of pathlib? For new code/projects would you treat os.path as deprecated or would you just use whatever is easier for you?
Yes; the former.

vikingstrike
Sep 23, 2007

whats happening, captain
I use pathlib 100% of the time now.

QuarkJets
Sep 8, 2008

I have never used pathlib, is it standard in 3.x or would you need to install it with pip

vikingstrike
Sep 23, 2007

whats happening, captain

QuarkJets posted:

I have never used pathlib, is it standard in 3.x or would you need to install it with pip

Standard as of 3.4

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
What's the use case for os.path or pathlib? If you're trying to load up a file included in your app/package why not include it in your setup.py as package_data and then use

code:
full_filename_and_path = pkg_resources.resource_filename(__name__, 'relative/path/to/file/from/package/root/file.txt')
? And if it's more like a user input file passed into a script how does pathlib/os.path help?

e:

I see this in the pathlib docs

code:
>>> p = Path('/etc')
>>> q = p / 'init.d' / 'reboot'
>>> q
PosixPath('/etc/init.d/reboot')
and it just seems like overloading the division sign to do this is making things harder and more complicated than it is.

Boris Galerkin fucked around with this message at 07:02 on May 17, 2018

QuarkJets
Sep 8, 2008

Boris Galerkin posted:

What's the use case for os.path or pathlib? If you're trying to load up a file included in your app/package why not include it in your setup.py as package_data and then use

code:
full_filename_and_path = pkg_resources.resource_filename(__name__, 'relative/path/to/file/from/package/root/file.txt')
? And if it's more like a user input file passed into a script how does pathlib/os.path help?


There are lots and lots of useful ways to use os.path (and presumably pathlib) but you could easily never encounter a need for it. Sometimes you're not just working with files that come up with app/package, sometimes you want to derive output file names from input file names, or do something in the same directory as a file, or sometimes you want to check whether a file or directory even exists before trying to do something with it, etc

quote:

I see this in the pathlib docs
code:
>>> p = Path('/etc')
>>> q = p / 'init.d' / 'reboot'
>>> q
PosixPath('/etc/init.d/reboot')
and it just seems like overloading the division sign to do this is making things harder and more complicated than it is.

I agree, this seems convoluted and bad. I assume (hope?) that people here aren't using it that way

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
pathlib is nice if you need to navigate around files and directories a lot, but if you're dealing with a fixed path then you don't really have much use for these Path objects. It also abstracts away a lot of OS specific stuff.

os.path can do much of the same things but pathlib has a much nicer API imo

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

QuarkJets posted:

I agree, this seems convoluted and bad. I assume (hope?) that people here aren't using it that way

This specific case of "fixed path / string / string" does seem convoluted and bad, but I've never really seen anyone do that in practice.

I use pathlib very extensively, and I use the overloaded / operator extremely often. It's really nice when having a Path representing a user-supplied or dynamic directory and wanting to refer to some hardcoded filename in that directory.

pathlib became much nicer to use in 3.6 also, since builtin IO functions now support path-like objects in addition to string paths. This means you can now do:

Python code:
with open(some_path_object) as f:
    do_something_with(f)
instead of having to call methods on the Path object, like:

Python code:
with some_path_object.open() as f:
    do_something_with(f)

vikingstrike
Sep 23, 2007

whats happening, captain
It always felt to me they overloaded / because os.path.join() tends to be quite verbose for what it does.

Thermopyle
Jul 1, 2003

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

Boris Galerkin posted:

What's the use case for os.path or pathlib? If you're trying to load up a file included in your app/package why not include it in your setup.py as package_data and then use

code:
full_filename_and_path = pkg_resources.resource_filename(__name__, 'relative/path/to/file/from/package/root/file.txt')
? And if it's more like a user input file passed into a script how does pathlib/os.path help?

e:

I see this in the pathlib docs

code:
>>> p = Path('/etc')
>>> q = p / 'init.d' / 'reboot'
>>> q
PosixPath('/etc/init.d/reboot')
and it just seems like overloading the division sign to do this is making things harder and more complicated than it is.

You use pathlib or os.path to do things to files. Sometimes you need to get the directory name of a file so you can write a file into the same directory. Sometimes you need to walk all the files in a directory tree. There's a ton of uses.

Overloaded division operator works well if you can get past the initial "culture shock". It's more succinct and by abstracting away the edge cases of joining path parts it makes your program clearer.

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord
I've got a real puzzling guy on my hands right now, could use outside thoughts.

Say we have some string:
'\x1b[1mThis is the string with some random ANSI garbage.\x1b(B\x1b[m'

That string has a length of n, but a printed length of x, where x is len(This is the string with some random ANSI garbage.).

I need to split lines whose printed len is > terminal width in order to display them properly.

My gut instinct is that I should strip all of the ANSI escape sequences from the strings, then use something like textwrap.wrap, then reinsert the ANSI stuff. This would involve some kind of tricky index tracking, and would be generally annoying.

Is there any simpler/more elegant way any of y'all can think of to solve this here problem?

QuarkJets
Sep 8, 2008

vikingstrike posted:

It always felt to me they overloaded / because os.path.join() tends to be quite verbose for what it does.

It seems about the same level of verbosity to me. It basically swaps a function call and commas for a constructor and slashes

Python code:
from os.path import join
x = join('a', 'path', 'to', 'my', 'porn', '2girls1cup.avi')

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies

The March Hare posted:

I've got a real puzzling guy on my hands right now, could use outside thoughts.

Say we have some string:
'\x1b[1mThis is the string with some random ANSI garbage.\x1b(B\x1b[m'

That string has a length of n, but a printed length of x, where x is len(This is the string with some random ANSI garbage.).

I need to split lines whose printed len is > terminal width in order to display them properly.

My gut instinct is that I should strip all of the ANSI escape sequences from the strings, then use something like textwrap.wrap, then reinsert the ANSI stuff. This would involve some kind of tricky index tracking, and would be generally annoying.

Is there any simpler/more elegant way any of y'all can think of to solve this here problem?
I'd probably subclass textwrap.TextWrapper to work mostly the same, just in that it ignores ANSI escape sequences in calculating the length of a given work chunk.

The March Hare
Oct 15, 2006

Je rêve d'un
Wayne's World 3
Buglord

Master_Odin posted:

I'd probably subclass textwrap.TextWrapper to work mostly the same, just in that it ignores ANSI escape sequences in calculating the length of a given work chunk.

Yep, that's a good idea.

Sad Panda
Sep 22, 2004

I'm a Sad Panda.

Master_Odin posted:

As vikingstrike said, if it's possible to generalize, you should try and do that. But if each site is unique enough that they require their own parser, your best bet is to store the scraping code in a DB or dynamically load it from a directory (I'd chose the latter as it'll be way easier to update and version control). But even in those cases, see if there isn't generalized helper functions you can write for it.

Well for example on one of the sites, my Selenium code looks like...

Python code:
def login(driver, username, password):
    # Inputs the username, tabs to the password, enters it and logs in.
    try:
        logging.info("Attempting login.")

        login_button = driver.find_element_by_id("accountTabButton")
        login_button.click()

        username_elem = driver.find_element_by_id("loginUsernameInput")
        username_elem.clear()
        username_elem.send_keys(username)
        username_elem.send_keys(Keys.TAB)
        element = driver.switch_to.active_element
        element.clear()
        element.send_keys(password)
        login_elem = driver.find_element_by_css_selector('[data-automation-id="loginButton"]')
        login_elem.click()
    except Exception as e:
        name = inspect.stack()[0][3]
        error_message(e, driver, name)
    logging.info("Logged in.")


def get_balance(driver):
    wait_for_presence(driver, By.CLASS_NAME, "account-tab__text")
    balance = driver.find_elements_by_class_name('account-tab__text')[0].text[1:]
    print(f"In get_balance, {balance}")
    logging.info(f"Balance is {balance}")
    return(balance)
For login(), some sites reqire clicking a button before the username + password input options are visible. Some can be identified by ID, some by class and some by css_selector. Some the elements are the only one visible of that name, whereas others it is the 2nd or 3rd so I use find_elements and interact with the 2nd or 3rd part of the array.
For the balance, it is usually visible, but the way of finding the element is always going to be different and also the part retrieved. That uses [1:] because the balance on that site is "£29.01" and I want to strip the £.

What do you mean by dynamically loading from the directory? This is the first project I've done that is anything more than a few static python files in a folder.

Linear Zoetrope
Nov 28, 2011

A hero must cook
In numpy (or some interoperable library like pandas) is there a way to create basic shapes like triangles or circles in an ndarray/tensor/table/whatever? I'm featurizing a space of entities represented like {pos = (x,y) , shape = Triangle{base_len = 1.5}, ...} or whatever and while I'm entirely capable of writing this myself* it would be nice to be able to just have python do it.

Specifically I have C channels, each of which represent a different aspect, such as hitpoints or a one-hot encoding of things like faction or unit type (domain is a custom RTS), and I'm trying to fill all of these channels based on the current state of the gameboard, but they have different primitive shapes and approximating them all as rectangles would overfill too much. I'm essentially looking to "rasterize" the (continuous-valued) game state, but with data other than colors, and then feed it into a NN. (I'm researching a way to represent this data as different sorts of NN inputs, but I need this crude representation for the time being as a baseline).

Unfortunately searching for anything relating to words like "triangle" or "shape" and "numpy" yield results about the shape property or triangular matrices so it's hard to find relevant info.

* In fact, I did write this myself in the engine in another language, but it's plagued with issues trying to intuit the "true" shape of the tensor from the python side, and I'm trying to move this to only sending over entity data as described and featurize it into an ndarray on the python side.

Linear Zoetrope fucked around with this message at 18:54 on May 18, 2018

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Thermopyle posted:

I'm having a hard time imagining your question even making conceptual sense, but that's probably just me being slow. Like, how do you imagine an event loop not running in another thread while at the same time not blocking the current thread?

FWIW, there's a list of some alternative event loops here.
I've concluded over the past week or so that coroutines are moon magic for most people so don't feel too bad about any of it. I suppose my situation is that I don't want an event "loop." Basically, take the outer loop off of run_forever and I'm most of the way there. Except, well, BaseEventLoop shits its pants if you do that. The third-party ones are lifting from native code, which will kill me if I'm trying to embed in Unity 3d. I managed to find one that's pure Python and was malleable to being manually ticked. I'm sure it has a lot of problems with particular kinds of Python coroutines and will need some coddling.

Now it's not like I'll have a coroutine yield for 5 seconds and then never get back to it. The idea is that I'd be ticking the event system in the regular Unity 3d event loop. So at least once every frame, everything gets a shot.

unpacked robinhood
Feb 18, 2013

by Fluffdaddy
I'm serializing classes in JSON to send them over an Ajax request and load those as data for a network graph in a web page.

For example:
Python code:
#!/usr/bin/python
import json
class Node:
    def __init__(self, id, value, label, color, group=''):
        self.id = id
        self.value = value
        self.label = label
        self.color = color
        self.group = group        

n = Node(8, "expensive", "sticky label", "red")
print(json.dumps({"node one": n.__dict__}))
# {"node one": {"color": "red", "group": "", "id": 8, "value": "expensive", "label": "sticky label"}} <-- GOOD

Gives me directly the key names the graph library expects, and can be parsed back and displayed fine.

I have trouble defining the edges because the library uses "from" and "to" keys, which are reserved words in python.
For example this is a valid edge declaration:
JavaScript code:
edges = [{title:'1',to:'10',from:'2',color:'rgb(100,100,100'},
{title:'1',to:'6',from:'2',color:'rgb(100,100,100'}]
but I can't simply declare:
Python code:
class Edge:
    def __init__(self, from, to, label, an_attribute):
		pass
At the moment I'm manually generating the json for the edges but that's really dirty. How do I do that correctly ?
e: I've switched to changing the key names in __dict__ before calling json.dumps()

unpacked robinhood fucked around with this message at 11:48 on May 19, 2018

Adbot
ADBOT LOVES YOU

Stringent
Dec 22, 2004


image text goes here

unpacked robinhood posted:

I'm serializing classes in JSON to send them over an Ajax request and load those as data for a network graph in a web page.

For example:
Python code:
#!/usr/bin/python
import json
class Node:
    def __init__(self, id, value, label, color, group=''):
        self.id = id
        self.value = value
        self.label = label
        self.color = color
        self.group = group        

n = Node(8, "expensive", "sticky label", "red")
print(json.dumps({"node one": n.__dict__}))
# {"node one": {"color": "red", "group": "", "id": 8, "value": "expensive", "label": "sticky label"}} <-- GOOD

Gives me directly the key names the graph library expects, and can be parsed back and displayed fine.

I have trouble defining the edges because the library uses "from" and "to" keys, which are reserved words in python.
For example this is a valid edge declaration:
JavaScript code:
edges = [{title:'1',to:'10',from:'2',color:'rgb(100,100,100'},
{title:'1',to:'6',from:'2',color:'rgb(100,100,100'}]
but I can't simply declare:
Python code:
class Edge:
    def __init__(self, from, to, label, an_attribute):
		pass
At the moment I'm manually generating the json for the edges but that's really dirty. How do I do that correctly ?

Rename the arguments.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply