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
Benji the Blade
Jun 22, 2004
Plate of shrimp.

supster posted:

This doesn't really make sense - you are implying that all functions in Python are virtual, but clearly it's working in the constructor. Is the __init__ function a special case and not virtual?

When you write self.foo, it looks "foo" up in the object's __dict__. When you write Parent.foo, it looks "foo" up in the class' __dict__. In this case, __init__ isn't a special case because you're (by way of super) calling the "__init__" from the class' __dict__, not from the object's __dict__. The one in the object's __dict__ is from the last class that defined it, in this case, Child.

You can sort of think of all methods being virtual.

supster posted:

If this is the case, is there specifically a different way I can access the base class's method that has been overriden?

BaseClass.method(self)

supster posted:

If x was a method in the base class I think I could just call Parent.x(self, value) and be fine, but because it is an attribute I can't do that.

Yes, but...

The issue is that Parent.x doesn't exist. If we have an object 'p' of type Parent, then the __init__() method will add attribute x to p ("p.x"), but in this case, it doesn't change anything in the class' namespace, only the object's.

Then, when you make an attribute x on class Child and call Parent.__init__(c) where c is an object of class Child, Parent.__init__ tries to set x on c, but since c is already a property (from the definition of class Child), it tries to call the setter.

I wish I could explain this better. Sorry I'm not doing a terribly good job of it.

Adbot
ADBOT LOVES YOU

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Benji the Blade posted:

When you write self.foo, it looks "foo" up in the object's __dict__. When you write Parent.foo, it looks "foo" up in the class' __dict__. In this case, __init__ isn't a special case because you're (by way of super) calling the "__init__" from the class' __dict__, not from the object's __dict__. The one in the object's __dict__ is from the last class that defined it, in this case, Child.
So are you saying that "__init__" in a class's dict will always be that class's constructor and "__init__" in an object's dict will always be that object's parent class's constructor (if it inherited from one)?

(Of course I am using the term "always" somewhat loosely here, I understand you can directly manupilate the dict and do other kinds of things.)


Benji the Blade posted:

The issue is that Parent.x doesn't exist.
Right. Because x is not a class method, it's an object attribute so the class's dict doesn't know about it, only a Parent object's dict would.


Benji the Blade posted:

If we have an object 'p' of type Parent, then the __init__() method will add attribute x to p ("p.x"), but in this case, it doesn't change anything in the class' namespace, only the object's.
Ok, I follow.

Benji the Blade posted:

Then, when you make an attribute x on class Child and call Parent.__init__(c) where c is an object of class Child, Parent.__init__ tries to set x on c, but since c is already a property (from the definition of class Child), it tries to call the setter.
Ok, I understand. So there's no internal instance of the parent object in the child object instance? I have no way of accomplishing what I am trying to do?

Benji the Blade posted:

I wish I could explain this better. Sorry I'm not doing a terribly good job of it.
I think you explained it well, thanks a lot. I am new to Python and not fully familiar with how a lot of things work interally yet, so this helps a lot.

supster fucked around with this message at 23:04 on Apr 6, 2009

Benji the Blade
Jun 22, 2004
Plate of shrimp.

supster posted:

So are you saying that "__init__" in a class's dict will always be that class's constructor and "__init__" in an object's dict will always be that object's parent class's constructor (if it inherited from one)?

The object's __init__ will start out as the __init__ from the object's class (if that class defined __init__). You can access the parent class' __init__ (and similarly anything in their namespaces) by either using Parent.__init__ or super(Child, c).__init__, which in this case does basically the same thing, but performs some black magic if you're doing multiple inheritance.

supster posted:

Ok, I understand. So there's no internal instance of the parent object in the child object instance? I have no way of accomplishing what I am trying to do?

Well, you could add a separate method or property that did the right thing, but then it wouldn't work with code that called the old property. You could instead use the adapter pattern to wrap the Parent rather than using inheritance, which I think is probably the right thing to do.

There might be a better way to do it, but I'd need to give it some thought.

I'm glad to hear it's been helpful. I promise once you get it, this is all a lot simpler than it sounds.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Benji the Blade posted:

You could instead use the adapter pattern to wrap the Parent rather than using inheritance, which I think is probably the right thing to do.
Does this work differently in Python than other languages? The reason I didn't want to do this was because the Parent class has another dozen or so attributes and methods that are being used, so I didn't want to have to have to change the usage of all of those to Adapater.Parent.method() or have to define all of those methods and attributes in my adapater class.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

supster posted:

Right. Because x is not a class method, it's an object attribute so the class's dict doesn't know about it, only a Parent object's dict would.

Ok, I understand. So there's no internal instance of the parent object in the child object instance? I have no way of accomplishing what I am trying to do?

Attributes and methods are the same thing. Variables in Python aren't segments of memory that can be set to some value -- they are labels that point to other objects.

The difficulty is that attributes/methods aren't separated based on their origin. You can't have "x" mean two different things in different methods, based on the method's class, without some black magic.

I'm trying to understand the goal of your code, but failing. The code is failing because the parent's x value isn't assigned to until the call to the child's property setter is complete. If you'd like to have a default value, use something like:

code:
class Parent:
    x = 0
    ...
If that's not your intention, could you write what you're trying to do using a language you're more familiar with? Then we could show you the best way to do the same thing in Python.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Janin posted:

If that's not your intention, could you write what you're trying to do using a language you're more familiar with? Then we could show you the best way to do the same thing in Python.
Good idea. Here's C#:
code:
class Program
{
    static void Main(string[] args)
    {
        Child c = new Child();
        c.x = 1;
        c.writenew();
        c.write();
    }
}

class Parent
{
    public int x = 0;

    public void write()
    {
        System.Console.WriteLine("Parent: {0}", this.x);
    }
}

class Child : Parent
{
    private int _x = 0;

    public int x
    {
        get { return this._x; }
        set
        {
            this._x = value;
            base.x = value + 1;
        }
    }

    public void writenew()
    {
        System.Console.WriteLine("Child: {0}", this.x);
    }
}
And the output:
code:
Child: 1
Parent: 2

supster fucked around with this message at 23:55 on Apr 6, 2009

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"
Yeah, you can't do that. In Python, there's no such thing as casting, because an object has only one type. Parent objects aren't "nested" within children.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Janin posted:

Yeah, you can't do that. In Python, there's no such thing as casting, because an object has only one type. Parent objects aren't "nested" within children.
I realized that using casting didn't make my goal clear. I understand you can't cast in Python. I edited my source, take a look again and see if that makes more sense. I want x to be different when accessed from the context of the Parent class than when accessed from the context of the Child class.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

supster posted:

I realized that using casting didn't make my goal clear. I understand you can't cast in Python. I edited my source, take a look again and see if that makes more sense. I want x to be different when accessed from the context of the Parent class than when accessed from the context of the Child class.

Python doesn't have contexts either. An object is the same, no matter what the code calling it thinks it is.

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH

Janin posted:

Python doesn't have contexts either. An object is the same, no matter what the code calling it thinks it is.
Gotcha - this was the key I was missing. That kind of sucks, but I understand. Thanks.

Are there any workarounds? I am only asking because I am curious, I would say that at this point designing around this limitation will almost always be a better solution than a hackish workaround.

supster fucked around with this message at 00:08 on Apr 7, 2009

Benji the Blade
Jun 22, 2004
Plate of shrimp.

supster posted:

The reason I didn't want to do this was because the Parent class has another dozen or so attributes and methods that are being used, so I didn't want to have to have to change the usage of all of those to Adapater.Parent.method() or have to define all of those methods and attributes in my adapater class.

Python helps you be lazy!

code:
class A(object):
    def f(self): return "base f()"
    def g(self, x): return "base g(%s)" % str(x)

class Adapter(object):
    def __init__(self, base):
        self.base = base

    def f(self): return "adapted f()"

    def __getattr__(self, name):
        return getattr(self.base, name)
And then,

code:
>>> a = A()
>>> adapt = Adapter(a)
>>> adapt.f()
'adapted f()'
>>> adapt.g(12)
'base g(12)'
Now, it doesn't matter how many attributes A has, you only have to override the ones you want, and anything not found in the "adapt" gets called on "adapt.base" via the __getattr__ method.

Edit: Used slightly clearer variable names.

Benji the Blade fucked around with this message at 16:48 on Apr 7, 2009

supster
Sep 26, 2003

I'M TOO FUCKING STUPID
TO READ A SIMPLE GRAPH
Thanks! This is exactly what I was trying to do. Normally I would have acheived this with inheritance, but it is obvious that in Python an adapter class is the way to go. Thanks for making this clear for me.

Captain Lou
Jun 18, 2004

buenas tardes amigo
I've been told that it's better not to use methods named __like_these__ unless you really have to -- this adapter class seems kinda hacky, is it not?

No Safe Word
Feb 26, 2005

Captain Lou posted:

I've been told that it's better not to use methods named __like_these__ unless you really have to -- this adapter class seems kinda hacky, is it not?

__getattr__ is a "special method" that is already defined on objects anyway, Benji is just overriding it.

__getattr__ just let's an object know what to do when something uses the dot operator on it, basically.

foo.bar

could be just as easily expressed:

foo.__getattr__('bar')

edit: actually you should never use __foo__ (both preceding and succeeding underscores) for a method name unless you're overriding an existing, but you should also "pretty much never" use __foo either, and should instead just use _foo

No Safe Word fucked around with this message at 16:40 on Apr 8, 2009

Benji the Blade
Jun 22, 2004
Plate of shrimp.

No Safe Word posted:

__getattr__ just let's an object know what to do when something uses the dot operator on it, basically.

foo.bar

could be just as easily expressed:

foo.__getattr__('bar')

Not to be pedantic, but foo.bar would be written foo.__getattribute__('bar'). __getattr__ only gets called for names not in foo.__dict__. *

The names "__getattr__" and "__getattribute__" having different meanings has always rubbed me the wrong way, but regardless, they are useful.

As far as not using names prefixed with __, No Safe Word is spot on, though overriding magic attributes (such as __getattr__) usually indicates there's magic afoot, which is sometimes warranted and sometimes a sign of being overly-clever. However, overriding methods like __init__ and __str__ and __iter__ are totally harmless and very often useful and even required.

* To actually be pedantic, I believe __getattr__ gets called when __getattribute__ throws some exception or other to indicate that it can't resolve name. Usually this is because name isn't in __dict__, but if you override __getattribute__ too, well, god knows what kinda bullshit you've written that may or may not throw an exception.

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...
A general programming question in a specific Pythonic context:

I have a webpage with a form (on a Plone site for what it matters), that when submitted calls an external program to do some calculations, grabs the results and renders them on the page. Simple. (For interest, it's matching submitted biosequences to an established corpus via various specialised commandline programs.)

The problem has come about that sometimes the server is overloaded or the external program fails to complete, leaving my webserver waiting for an answer that never comes. So: what's the appropriate Pythonic idiom for handling this sort of situation? It seems reasonable to launch the external app, wait for x seconds and then conclude it has failed and return a "sorry" message to the user. Threads, job control, multiprocessing - what's the best way to it?

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

Does anyone know of a good directory browsing module? I'm currently using FileDialog, but it's really lovely.

Spime Wrangler
Feb 23, 2003

Because we can.

he;lp

I'm coding an agent-based simulation of a production system right now as a term project for a modeling/simulation class (NOT a programming class!), and made the glorious decision to simultaneously learn a new language AND object-oriented programming at the same time, and am having issues. I have extensive matlab experience, and am somewhat confused as to how python handles certain tasks. Apparently I'm confused about the intricacies of pass-by-value vs. pass-by-reference.

Specifically, I have items that need to be passed from agent (person on factory floor) to agent and modified by the agents along the way. I have a class Item() which is inherited by the classes Part() and Assembly(), with Assemblies being multiple Parts joined together, and which look just like parts as far as agents are concerned.

I need to be able to pass these items from agent to agent as well as keep track of all items that are in use.

What is the best way to go about doing this?

Can I/should I have a (global?) dictionary whose keys are the unique item ID number and whose entries are Items themselves, and pass only the ID numbers from agent to agent?

If I pass an agent an Item in a dictionary or list, and have that agent modify an attribute of the Item, and then give it to another agent, is it still the exact same Item as in the list?

Or would I be better off shuttling around the actual Items themselves, and tracking them some other way?

Sorry if this is an inappropriate or confusing question, and thanks for any help!

deimos
Nov 30, 2006

Forget it man this bat is whack, it's got poobrain!

Spime Wrangler posted:

:words:

Core Python has great explanations for objects, variables and memory in chapters 3 and 4, fortunately google books has the material available!

edit: bah actually missing page 83 which has the beginning of the explanation.

Spime Wrangler
Feb 23, 2003

Because we can.

Ok, that explains it pretty well, I think. Thanks!

Edit: ok yeah python loving rocks this poo poo makes so much more sense now

It's so different from the way matlab works... I could get used to these "objects" and "pass-by-reference" and "pythonic" things. I decided to completely take the plunge and am also using VIM and linux for the first time and I'm just hitting the point where I feel it's worth it and no longer considering going back to windows. It's been a pretty solid brainfuck for the past few days. Reading through this thread has helped a lot, so thank you guys for doing this.

Spime Wrangler fucked around with this message at 07:14 on Apr 9, 2009

tripwire
Nov 19, 2004

        ghost flow

Spime Wrangler posted:

Ok, that explains it pretty well, I think. Thanks!

Edit: ok yeah python loving rocks this poo poo makes so much more sense now

It's so different from the way matlab works... I could get used to these "objects" and "pass-by-reference" and "pythonic" things. I decided to completely take the plunge and am also using VIM and linux for the first time and I'm just hitting the point where I feel it's worth it and no longer considering going back to windows. It's been a pretty solid brainfuck for the past few days. Reading through this thread has helped a lot, so thank you guys for doing this.

Welcome to the inner circle :twisted:

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!
I'm using python with mod_wsgi, and I'm unsure if something I am doing is making my code "not thread safe": I am storing stateful (per request) data in a property in some of my classes. Does this mean that if I run a threaded server, that data could be shared between simultanious requests?

king_kilr
May 25, 2007
That depends, are you storing data on the class itself, or just on instances? If it's on the class itself your data isn't threadsafe(unless you're dynamically creating classes per request), if it's on the instance the question is whether or not you're sharing the instances across requests.

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

king_kilr posted:

That depends, are you storing data on the class itself, or just on instances? If it's on the class itself your data isn't threadsafe(unless you're dynamically creating classes per request), if it's on the instance the question is whether or not you're sharing the instances across requests.

Yea, I'm setting an instance as a property of a class, for every request (done in Django middleware to save me passing this drat variable back and forth between the views that have access to the request object and the models that don't; i broke mvc).

So that isn't thread safe.. What if a module creates an instance of one of it's classes? (like at the end of django/contrib/admin/sites.py). I assume that isn't shared between threads?

king_kilr
May 25, 2007
That is absolutely shared between threads, any global is.

NightGyr
Mar 7, 2005
I � Unicode
I installed python 3.0 on this system for some reason, and its for / range() syntax seems to hate me:

code:
>>> for x in range(10):
	print x
	
SyntaxError: invalid syntax (<pyshell#26>, line 2)
What am I missing?

Edit:

gently caress me, it's the print vs. print() syntax.

Go IDLE, highlighting the line that *didn't* have the problem on it to confuse me.

NightGyr fucked around with this message at 02:29 on Apr 10, 2009

bitprophet
Jul 22, 2004
Taco Defender

NightGyr posted:

I installed python 3.0 on this system for some reason, and its for / range() syntax seems to hate me:

code:
>>> for x in range(10):
	print x
	
SyntaxError: invalid syntax (<pyshell#26>, line 2)
What am I missing?

http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function

No Safe Word
Feb 26, 2005

NightGyr posted:

I installed python 3.0 on this system for some reason, and its for / range() syntax seems to hate me:

code:
>>> for x in range(10):
	print x
	
SyntaxError: invalid syntax (<pyshell#26>, line 2)
What am I missing?

Edit:

gently caress me, it's the print vs. print() syntax.

Go IDLE, highlighting the line that *didn't* have the problem on it to confuse me.

It does say line 2 ... I can't see the highlighting but ...

Mashi
Aug 15, 2005

Just wanted you to know your dinner's cold and the children all agree you're a shitheel!

king_kilr posted:

That is absolutely shared between threads, any global is.

What about storing global data as a property of the current thread? Something like this:

code:
import threading, random

# in middleware.py
class MyMiddleware:
    def process_request(self, request):
        threading.currentThread().request = request
        request.foo = random.randint(1, 1000)

# in models.py
class Somemodel:
    def get_absolute_url(self):
        foo = threading.currentThread().request.foo
        return '/something/%s/' % str(foo)
I tested this method against a multithreaded dev server and it seems to work. Obviously I understand that this reduces portability, but is it terrible for some other reason?

edit: just found out that threading.local() exists for exactly this purpose

another edit: so Django already has django.utils.thread_support for this, but why does it go to such great lengths to implement it? It seems that I've left the GIL out of my example.

Mashi fucked around with this message at 01:39 on Apr 11, 2009

king_kilr
May 25, 2007
Yes, you can do that and it is threadsafe, however needing to do that is almost universally a sign of poor architecture of your application.

mister_gosh
May 24, 2002

EDIT: Nevermind, found this very helpful- http://oreilly.com/catalog/pythonwin32/chapter/ch12.html

I've been using a private (yet commercial) API in Perl and Java for awhile. Their API is COM and CORBA. I have a desire to move some of this code to a web framework. I tried Ruby on Rails, but it doesn't work well with COM and other things I need to do. The idea of Jython intrigues me eventually, and I'm hoping to go with Django here.

I'd like to do a proof of concept using Python and want to see if I can get Python to interact with the COM api correctly. I've attempted to google, but it's either a simple concept which doesn't get many hits, or I don't know how to word it.

Given that Perl is a little more similar to Python than Java, I'll post some of my Perl code. I'm wondering if you could help me translate this to Python?

code:
use ACME;
use lib::AcmeWidget;

ACME::set_error(1);

$conn = ACME->new("AcmeClient.AcmeConnection");
if (! $conn) {
  print "error";
  exit(1);
}

eval {
  $obj = $conn->Connect("mydb");
  $obj->dothis("abc");
  $obj->dothat("xyz");
};
AcmeClient exists as a DLL, so I could import it, but is that what I want?

This is as far as I got, but I don't know what I'm doing.

code:
from ctypes import *
print windll.kernel32 
print cdll.msvcrt 

cdll.LoadLibrary("AcmeClient")
acmeClientApi = CDLL("AcmeClient")

mister_gosh fucked around with this message at 16:09 on Apr 13, 2009

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
I feel like I should've seen something on the subject before, but I can't seem to find anything.

Why is it that when you want to join a list of elements with a separator string, you call separator.join(a_sequence)? It never made any sense to me, and I always get it wrong because I think it makes more sense to call join on the sequence (i.e. seq.join(',')). I don't mean to start a holy war, I really don't care; I just think that maybe I'd remember it better if I knew why it's done this way.

Scaevolus
Apr 16, 2007

pokeyman posted:

Why is it that when you want to join a list of elements with a separator string, you call separator.join(a_sequence)?
If it were seq.join(','), every sequence would have to implement the function. With it being str.join, you can take any iterable of strings and produce a joined string. It's cleaner overall and reduces duplication, even if the syntax isn't quite as intuitive as having the separator after the sequence.

str.join is better than tuple.join AND list.join AND my_derived_type.join AND ...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
That makes sense. I always got tripped up, as I thought of it as "why should the string handle putting itself between items of a sequence". I should've considered the implementation. Thanks!

Zombywuf
Mar 29, 2008

Another join question, can anyone tell me what is going on here:
code:
    param_str = '|'.join(['' if x is None else x for x in params])

TypeError: sequence item 2: expected string, NoneType found
The list comprehension should be replacing all instances of None with '', so why is join complaining about finding a NoneType?

Edit: Python's reporting the error from the source file not the code it's actually executing behavior strikes again. I was bouncing the wrong service to do my testing, and python was reporting errors in the fixed code...

Zombywuf fucked around with this message at 12:00 on Apr 14, 2009

nonathlon
Jul 9, 2004
And yet, somehow, now it's my fault ...
I've been Doing The Right Thing and using setuptools to handle the installation of all the modules I write. But I recently wrote a few scripts, that I thought others might find useful. (They do conversion between various bioinformatic file formats.) When thinking about the best way to distribute it, I realised that setuptools would work fine. You can give it a version, that can be updated. It takes care of the prerequisites. It can copy a script to the right place.

It does install an egg in the site-packages dir, but the egg appears to be non-importable. So it seems to work fine. Can anyone think of any objections or potential problems?

mister_gosh
May 24, 2002

I can't seem to get cx_Oracle to be recognized, and I've googled. I have Oracle 10.1.0.5 client (server is on the intranet) and Python 2.6 on my machine. I've tried installing multiple versions of cx_Oracle from SourceForge with the same result (4.x, 5.0 and 5.1 all for Python 2.6). All give me this error:

code:
>>> import cx_Oracle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified procedure could not be found.
One google note I found was possibly running:
code:
regsvr32 C:\Python26\Lib\site-packages\cx_Oracle.pyd 
But that didn't help. It said:
code:
LoadLibrary("C:\Python26\Lib\site-packages\cx_Oracle.pyd") failed - The specified module could not be found.
... which it does exist. I even used the [ tab ] key to auto-fill the path in the command prompt.

Any ideas?

blitrig
Jul 2, 2003
If I have an XML doc like this:

<?xml version="1.0" encoding="UTF-8"?>
<names>
<name>John</name>
<name>Mary</name>
<name>Frank</name>
<name>Steve</name>
<name>Sally</name>
</names>

How would I go from the XML to getting each individual name as an element in a Python set? As in:

set(['John', 'Mary', 'Frank', 'Steve', 'Sally'])

At first I thought this would be simple given that Python is magical, but it's giving me hell. This could be because it's actually complicated (which I doubt), or because I'm a complete python noob.

Any ideas?

mystes
May 31, 2006

blitrig posted:

If I have an XML doc like this:

<?xml version="1.0" encoding="UTF-8"?>
<names>
<name>John</name>
<name>Mary</name>
<name>Frank</name>
<name>Steve</name>
<name>Sally</name>
</names>

How would I go from the XML to getting each individual name as an element in a Python set? As in:

set(['John', 'Mary', 'Frank', 'Steve', 'Sally'])

At first I thought this would be simple given that Python is magical, but it's giving me hell. This could be because it's actually complicated (which I doubt), or because I'm a complete python noob.

Any ideas?
set(re.findall("<name>(.*?)</name>",yourxmlstring))

Adbot
ADBOT LOVES YOU

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

blitrig posted:

If I have an XML doc like this:

http://docs.python.org/library/xml.etree.elementtree.html

Parse the text into a document node, then use:

set(e.text for e in doc.findall('name'))

I don't have Python installed on this system, so this is untested :shobon:

mystes posted:

XML + regular expressions

No, never do this

  • Locked thread